<!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]" &lt;<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4426249&i=0" target="_top" rel="nofollow">[hidden email]</a>&gt;
</div><div><b>Date: </b>Wed, 20 Jan 2010 03:22:02 -0800 (PST)</div><div><b>To: </b>Afroz Kannancheri&lt;<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4426249&i=1" target="_top" rel="nofollow">[hidden email]</a>&gt;</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>&gt; Hi all,
<br>&gt;
<br>&gt; I have a Vector layer over a google base map as 
<br>&gt;
<br>&gt; map                 = new OpenLayers.Map('map',map_options);
<br>&gt; var google         = new OpenLayers.Layer.Google(&quot;Google
<br>&gt; Physical&quot;,google_Poptions);
<br>&gt; layer1                 = new OpenLayers.Layer.GML(&quot;G1&quot;, &quot;D2data.json&quot;, {
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: OpenLayers.Format.GeoJSON, 
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; styleMap: build_style(), 
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isBaseLayer: false});
<br>&gt;                         
<br>&gt; map.addLayers([google,layer1]);
<br>&gt;
<br>&gt; I have a function which runs every N seconds to update the Geojson layer by
<br>&gt; getting
<br>&gt; the new D2data.json geojson file generated in the server.
<br>&gt;
<br>&gt; The update function is as follows
<br>&gt; function UpdateLayer()
<br>&gt;         {
<br>&gt;         
<br>&gt;         var protocol = new OpenLayers.Protocol.HTTP({ 
<br>&gt; &nbsp; &nbsp; url: &quot;<a href="http://localhost/mystuff/s/D2data.json?sid=" target="_top" rel="nofollow" link="external">http://localhost/mystuff/s/D2data.json?sid=</a>&quot;+Math.random(), 
<br>&gt; &nbsp; &nbsp; format: new OpenLayers.Format.GeoJSON() 
<br>&gt;         }); 
<br>&gt;
<br>&gt;         protocol.read({ 
<br>&gt;                 callback: function(response) { 
<br>&gt;                         if(response.success()) { 
<br>&gt;                                 var features = response.features; 
<br>&gt;                                 map.layers[1].destroyFeatures();
<br>&gt;                                 for(k in features)
<br>&gt;                                 {
<br>&gt;                                         map.layers[1].addFeatures([features[k]]);
<br>&gt;                                 }
<br>&gt;                         } else { 
<br>&gt;                                 console.log(&quot;failure&quot;); 
<br>&gt;                         } 
<br>&gt;                 } 
<br>&gt;         }); 
<br>&gt; &nbsp;}
<br>&gt;
<br>&gt; &nbsp;In the above function, I destroy the existing features and fetch new
<br>&gt; features from the server and add them on the layer.
<br>&gt; &nbsp;The destroyFeatures() is working fine, but the addFeatures doesnt do
<br>&gt; anything.
<br>&gt; &nbsp;
<br>&gt; &nbsp;It would be of great help if someone could pointout whats wrong in this.
<br>&gt; &nbsp;
<br>&gt; &nbsp;Thanks &nbsp;and regards
<br>&gt; &nbsp;Afroz
<br>&gt; &nbsp;
<br>&gt;                         
<br>&gt;
<br>&gt; &nbsp; 
</div></div><br>-- 
<br><br><br>&nbsp; Dipl.-Geogr. Marc Jansen
<br>&nbsp; - Anwendungsentwickler -
<br><br>&nbsp; terrestris GmbH & Co. KG
<br>&nbsp; Irmintrudisstraße 17
<br>&nbsp; 53111 Bonn
<br><br>&nbsp; Tel: &nbsp; &nbsp;++49 (0)228 / 96 28 99 -53
<br>&nbsp; Fax: &nbsp; &nbsp;++49 (0)228 / 96 28 99 -57
<br><br>&nbsp; Email: &nbsp;<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>&nbsp; Web: &nbsp; &nbsp;<a href="http://www.terrestris.de" target="_top" rel="nofollow" link="external">http://www.terrestris.de</a><br><br>&nbsp; Amtsgericht Bonn, HRA 6835
<br>&nbsp; Komplementärin: &nbsp;terrestris Verwaltungsgesellschaft mbH
<br>&nbsp; vertreten durch: Hinrich Paulsen, Till Adams &nbsp;
<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>