<div>Oops, let's make that example more generic(!)</div><div><br></div><div>//===========================</div><div>lyrNum = 2;</div><div><div>var delta = map.getNumLayers() - lyrNum;</div><div><br></div><div>map.raiseLayer(layer_e, -delta);</div>
<div>map.raiseLayer(layer_b, delta);</div></div><div>//===========================</div><div><br></div><div>Jason</div><br class="Apple-interchange-newline"><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 10:26 AM, Jason Lee <span dir="ltr"><<a href="mailto:jaslee.st@gmail.com" target="_blank">jaslee.st@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Don't know if it is the best solution, but I am now using "map.raiseLayer()" like so:-</div><div><br>
</div><div>//===========================</div><div>lyrNum = 2;</div><div><div>var delta = map.getNumLayers() - lyrNum;</div>
<div><br></div><div>map.raiseLayer(layer, -delta);</div><div>map.raiseLayer(netLayer, delta);</div></div><div><div>//===========================</div><br></div><div>This seems to do the trick.</div><span class="HOEnZb"><font color="#888888">
<div><br></div><div>Jason</div></font></span><div class="HOEnZb"><div class="h5"><div><br></div><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 9:55 AM, Jason Lee <span dir="ltr"><<a href="mailto:jaslee.st@gmail.com" target="_blank">jaslee.st@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div>I have an OpenLayers application which initially has 4 layers, called (a),(b),(c) & (d). The app then allows the creation of a new layer (e) which I want it to "swap" places with layer (b) so that the order should be (a),(e),(c),(d),(b).</div>


<div><br></div><div>I use the map.setLayerIndex and layer.getZIndex to try and do this but I realise that the layers are in a FIFO like queue, so when I temporarily re-assign layer (b) the other layers automatically reorder themselves to (a),(c),(d),(e) ...or at least that's what I think it happening.</div>


<div><br></div><div>Could anyone show me how I can simply swap the z-order of 2 layers?</div><div><br></div><div>Thanks</div><span><font color="#888888"><div><br></div><div>Jason</div>
</font></span></blockquote></div><br>
</div></div></blockquote></div><br>