I am using openlayers to visualize an industry using image as the layer. On the raster layer I have created an overlay layer.Is it possible to show updated values (dynamic runtime values - as integer) in the overlay layer that gets updated every second? If so please help me how to get this done in openlayers.
1 Answer
You can do it with features on a vector layer. Provide a datasource that has features on the same coordinates than your features on the raster layer. Then you can access the attributes of these features. For example, population:
myvectorlayer.features[myfeatureindex].attributes.population = 10000;
(or use one of the myvectorlayer.getFeature* functions)
From now on, you can add a label for the features with Openlayers.Style :
var myStyle = new OpenLayers.Style({
'label' : '${population}',
'fontSize' : '8px',
'fontColor' : 'white',
'labelOutlineColor' : "#000000",
'labelOutlineWidth' : 2});
Where ${population} is the attributes name on the vector layers features.