<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> I ll try that nd update u . Thnx a lot<p>Sent from my BlackBerry® smartphone from du</p><hr /><div><b>From: </b> "Marc Jansen-2 [via OSGeo.org]" <<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4426249&i=0" target="_top" rel="nofollow">[hidden email]</a>>
</div><div><b>Date: </b>Wed, 20 Jan 2010 03:22:02 -0800 (PST)</div><div><b>To: </b>Afroz Kannancheri<<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4426249&i=1" target="_top" rel="nofollow">[hidden email]</a>></div><div><b>Subject: </b>Re: [OpenLayers-Users] Problem Updating dynamic Geojson layer</div><div><br /></div> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
Hi Afroz,
<br><br>I'd guess that
<br><br>features[k]
<br><br>is not an instance of OpenLayers.Feature.XXX, is it?
<br><br>If not you'll need to transform the thing you have
<br>into an appropriate OL-feature and add it afterwards.
<br><br>Regards,
<br>Marc
<br><br><br><br>Afroz Kannancheri wrote:
<div class='shrinkable-quote'><div class='shrinkable-quote'><br>> Hi all,
<br>>
<br>> I have a Vector layer over a google base map as
<br>>
<br>> map                 = new OpenLayers.Map('map',map_options);
<br>> var google         = new OpenLayers.Layer.Google("Google
<br>> Physical",google_Poptions);
<br>> layer1                 = new OpenLayers.Layer.GML("G1", "D2data.json", {
<br>> format: OpenLayers.Format.GeoJSON,
<br>> styleMap: build_style(),
<br>> isBaseLayer: false});
<br>>                         
<br>> map.addLayers([google,layer1]);
<br>>
<br>> I have a function which runs every N seconds to update the Geojson layer by
<br>> getting
<br>> the new D2data.json geojson file generated in the server.
<br>>
<br>> The update function is as follows
<br>> function UpdateLayer()
<br>>         {
<br>>         
<br>>         var protocol = new OpenLayers.Protocol.HTTP({
<br>> url: "<a href="http://localhost/mystuff/s/D2data.json?sid=" target="_top" rel="nofollow" link="external">http://localhost/mystuff/s/D2data.json?sid=</a>"+Math.random(),
<br>> format: new OpenLayers.Format.GeoJSON()
<br>>         });
<br>>
<br>>         protocol.read({
<br>>                 callback: function(response) {
<br>>                         if(response.success()) {
<br>>                                 var features = response.features;
<br>>                                 map.layers[1].destroyFeatures();
<br>>                                 for(k in features)
<br>>                                 {
<br>>                                         map.layers[1].addFeatures([features[k]]);
<br>>                                 }
<br>>                         } else {
<br>>                                 console.log("failure");
<br>>                         }
<br>>                 }
<br>>         });
<br>> }
<br>>
<br>> In the above function, I destroy the existing features and fetch new
<br>> features from the server and add them on the layer.
<br>> The destroyFeatures() is working fine, but the addFeatures doesnt do
<br>> anything.
<br>>
<br>> It would be of great help if someone could pointout whats wrong in this.
<br>>
<br>> Thanks and regards
<br>> Afroz
<br>>
<br>>                         
<br>>
<br>>
</div></div><br>--
<br><br><br> Dipl.-Geogr. Marc Jansen
<br> - Anwendungsentwickler -
<br><br> terrestris GmbH & Co. KG
<br> Irmintrudisstraße 17
<br> 53111 Bonn
<br><br> Tel: ++49 (0)228 / 96 28 99 -53
<br> Fax: ++49 (0)228 / 96 28 99 -57
<br><br> Email: <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4425935&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br> Web: <a href="http://www.terrestris.de" target="_top" rel="nofollow" link="external">http://www.terrestris.de</a><br><br> Amtsgericht Bonn, HRA 6835
<br> Komplementärin: terrestris Verwaltungsgesellschaft mbH
<br> vertreten durch: Hinrich Paulsen, Till Adams
<br><br><br>_______________________________________________
<br>Users mailing list
<br><a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4425935&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br><a href="http://openlayers.org/mailman/listinfo/users" target="_top" rel="nofollow" link="external">http://openlayers.org/mailman/listinfo/users</a><br>
<br rel='nabble-footer-start' /><br />
<hr noshade="noshade" size="1" color="#cccccc" />
<div style="color:#666666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;">
View message @ <a href="http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4425935.html" target="_top" rel="nofollow" link="external">http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4425935.html</a>
<br>To unsubscribe from Problem Updating dynamic Geojson layer, <a target="_top" rel="nofollow" link="external">click here</a>.
</div>
<br rel='nabble-footer-end' />
<br><hr align="left" width="300">
View this message in context: <a href="http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4426249.html">Re: [OpenLayers-Users] Problem Updating dynamic Geojson layer</a><br>
Sent from the <a href="http://n2.nabble.com/OpenLayers-Users-f1822463.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br>