[OpenLayers-Users] Problem Updating dynamic Geojson layer
Afroz Kannancheri
afrozk at gmail.com
Wed Jan 20 05:14:15 EST 2010
Hi all,
I have a Vector layer over a google base map as
map = new OpenLayers.Map('map',map_options);
var google = new OpenLayers.Layer.Google("Google
Physical",google_Poptions);
layer1 = new OpenLayers.Layer.GML("G1", "D2data.json", {
format: OpenLayers.Format.GeoJSON,
styleMap: build_style(),
isBaseLayer: false});
map.addLayers([google,layer1]);
I have a function which runs every N seconds to update the Geojson layer by
getting
the new D2data.json geojson file generated in the server.
The update function is as follows
function UpdateLayer()
{
var protocol = new OpenLayers.Protocol.HTTP({
url: "http://localhost/mystuff/s/D2data.json?sid="+Math.random(),
format: new OpenLayers.Format.GeoJSON()
});
protocol.read({
callback: function(response) {
if(response.success()) {
var features = response.features;
map.layers[1].destroyFeatures();
for(k in features)
{
map.layers[1].addFeatures([features[k]]);
}
} else {
console.log("failure");
}
}
});
}
In the above function, I destroy the existing features and fetch new
features from the server and add them on the layer.
The destroyFeatures() is working fine, but the addFeatures doesnt do
anything.
It would be of great help if someone could pointout whats wrong in this.
Thanks and regards
Afroz
--
View this message in context: http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4425671.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list