Note that there are some explanatory texts on larger screens.

plurals
  1. POClear WMS layer before redraw on OpenLayers
    primarykey
    data
    text
    <p>I'm currently successfully displaying multiple layers using OpenLayers (Vector and WMS). My application allow the user to modify some parameters, which will :<br> * modify bound<br> * modify map center<br> * modify the WMS image<br> I use Ajax to avoid page reload, it works nicely, however when some layers take a while to load, the others which are not yet redrawn are still shown in the background (but aren't related at all to my new context). I would like to clear WMS layers (if possible) before re-asking the server for the new image but didn't find anything yet. I do this on the vector layer by calling removeAllFeature();</p> <p>Thanks for any help !</p> <p>Here is my pseudo-code when the user click the button :</p> <pre><code>$.getJSON("url/updateMapConfig.php", { data: $(this).serialize() , ajax: 'true', cache: 'false' }, function(j){ if (j.result == 'ok') { var layersToShow = []; // Refresh vector layer for(var i=0;i&lt;map.layers.length;i++) { if (map.layers[i].isVector) { map.layers[i].removeAllFeatures(); map.layers[i].refresh({force:true}); // Vector layer } } // Refresh visible layers for(var i=0;i&lt;map.layers.length;i++) { if (map.layers[i].visibility &amp;&amp; !map.layers[i].isBaseLayer &amp;&amp; !map.layers[i].isVector) { // Refresh visible non base map.layers[i].redraw(true); // Other layer } } // Set new bounds var bounds = new OpenLayers.Bounds(); bounds.extend(new OpenLayers.LonLat(j.bounds.xmin-100, j.bounds.ymin-100)); bounds.extend(new OpenLayers.LonLat(parseInt(j.bounds.xmax)+100, parseInt(j.bounds.ymax)+100)); map.zoomToExtent(bounds); // Move to destination point if (j.poiCenter != "") { eval("map.setCenter(new OpenLayers.LonLat("+j.poiCenter+"))"); } } } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload