[OpenLayers-Users] Problem Updating dynamic Geojson layer

Afroz Kannancheri afrozk at gmail.com
Wed Jan 20 07:41:09 EST 2010


I ll try that nd update u . Thnx a lot
Sent from my BlackBerry® smartphone from du

-----Original Message-----
From: "Marc Jansen-2 [via OSGeo.org]" <ml-node+4425935-499877898 at n2.nabble.com>
Date: Wed, 20 Jan 2010 03:22:02 
To: Afroz Kannancheri<afrozk at gmail.com>
Subject: Re: [OpenLayers-Users] Problem Updating dynamic Geojson layer




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:  jansen at 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 at openlayers.org
http://openlayers.org/mailman/listinfo/users


______________________________________
View message @ http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4425935.html

To unsubscribe from Problem Updating dynamic Geojson layer, click  (link removed) ==


-- 
View this message in context: http://n2.nabble.com/Problem-Updating-dynamic-Geojson-layer-tp4425671p4426249.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100120/b7a2afe1/attachment.html


More information about the Users mailing list