0

I have 6 different layers. Some are layers with markers and some other with raster data. In some point, when I zoom in the map, I create a vector layer. Upon adding the layer on the map I want a specific WMS layer to appear above the vector layer. That's why I do this:

map.setLayerIndex(wms_layer_network, map.layers.length+100);

Although the layer indeed change position and comes to the top, on my map I don't see this change. The vector layer keeps being on top of the WMS. This is how I check the layer array and their position (assuming the last value of the array is the one which will appear on top):

 var mLayers = map.layers;
 for(var a = 0; a < mLayers.length; a++ ){
 alert(mLayers[a].name)
 };

Does anyone know why this happens?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Apr 8, 2015 at 14:32

1 Answer 1

1

The map.layers.length only gives you the array size of the layers with the map but not the zindexes of those layers as specific ranges are used depending on what is being displayed. So, one possibility would be to add the vector layer, get its zindex, get the WMS zindex, and see if swapping the two would work for you, i.e.

var vectorindex = map.getLayerIndex(vector);
var WMSindex = map.getLayerIndex(WMS);
map.setLayerIndex(vector, WMSindex);
map.setLayerIndex(WMS, vectorindex);

where WMS and vector are the layers of course. You could also use the layer methods, getZIndex() and setZIndex(integer) to get/set the layer index as well.

answered Jun 16, 2015 at 15:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.