<br><br>On Saturday, May 5, 2012, alexe100  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
I have a map which embedds :<br>
<br>
var layer = new OpenLayers.Layer.OSM(...<br>
var vectorLayer = new OpenLayers.Layer.Vector(...<br>
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;<br>
and<br>
var selectControl = new OpenLayers.Control.SelectFeature(...<br>
<br>
It shows very well including vectors and tooltips.<br>
<br>
On the html page i have a check box called Automatic Refresh. If i check<br>
this control a timer is set with a period of 5 secods.<br>
For each 5 seconds the page requests new (current) GPS positions from the<br>
servlet for the vehicles.<br>
When those positions arrive I clear the structure vector and store the new<br>
positions and then  I need to update the positions on the map. To simplify<br>
the operation I do this:<br>
<br>
for (var i = map.layers.length - 1; i &gt;= 0; i--)<br>
                {<br>
                        map.removeLayer(map.layers[i]);<br>
                }<br>
<br>
and then I call Init() again to create the (new) map<br>
<br>
<br>
but the map does not show very well. It seems that part of the old map<br>
remains on the bottom of the screen/div and the new map is drawn above it.<br>
<br>
Is this the right way to do the map update?</blockquote><div><br></div><div><br></div><div>Use map.destroy() to destroy a map entirely.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Can I simple update only the layer on the vehicles positions icons? if so,<br>
what about the already stablished SelectFeatures for that layer? Do I have<br>
to delete them too? how?</blockquote><div><br></div><div>You can do vectorLayer.destroyFeatures() to empty the layer and then add the new poditions.</div><div><br></div><div>Also, you may want to look at the Refresh strategy.</div>
<div><br></div><div>Cheers,<span></span></div><br><br>-- <br>Eric Lemoine<br><br>Camptocamp France SAS<br>Savoie Technolac, BP 352<br>73377 Le Bourget du Lac, Cedex<br><br>Tel : 00 33 4 79 44 44 96<br>Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com">http://www.camptocamp.com</a><br><br>