Hi Afroz, I'd guess that
features[k] is not an instance of OpenLayers.Feature.XXX, is it? If not you'll need to transform the thing you have into an appropriate OL-feature and add it afterwards. Regards, Marc Afroz Kannancheri wrote: > 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 > > > > -- Dipl.-Geogr. Marc Jansen - Anwendungsentwickler - terrestris GmbH & Co. KG Irmintrudisstraße 17 53111 Bonn Tel: ++49 (0)228 / 96 28 99 -53 Fax: ++49 (0)228 / 96 28 99 -57 Email: jan...@terrestris.de Web: http://www.terrestris.de Amtsgericht Bonn, HRA 6835 Komplementärin: terrestris Verwaltungsgesellschaft mbH vertreten durch: Hinrich Paulsen, Till Adams _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users