[OpenLayers-Users] How to completely erase a map?

alexe100 imoveisnacionais at gmail.com
Fri May 4 22:43:28 EDT 2012


Hi 

I have a map which embedds :

var layer = new OpenLayers.Layer.OSM(...
var vectorLayer = new OpenLayers.Layer.Vector(...
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
and
var selectControl = new OpenLayers.Control.SelectFeature(...

It shows very well including vectors and tooltips.

On the html page i have a check box called Automatic Refresh. If i check
this control a timer is set with a period of 5 secods.
For each 5 seconds the page requests new (current) GPS positions from the
servlet for the vehicles.
When those positions arrive I clear the structure vector and store the new
positions and then  I need to update the positions on the map. To simplify
the operation I do this:

for (var i = map.layers.length - 1; i >= 0; i--) 
		{
			map.removeLayer(map.layers[i]);
		}

and then I call Init() again to create the (new) map 
	

but the map does not show very well. It seems that part of the old map
remains on the bottom of the screen/div and the new map is drawn above it.

Is this the right way to do the map update?

Can I simple update only the layer on the vehicles positions icons? if so,
what about the already stablished SelectFeatures for that layer? Do I have
to delete them too? how?



Thanks a lot

Alex


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-completely-erase-a-map-tp4953741.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list