How to set which wms layer is shown on top?

531
1
Jump to solution
03-19-2012 06:57 AM
ChadFanguy
New Contributor III
I would like to set which wms layer that is shown on top. I assume I set it with the z-index, but how would I do this?
0 Kudos
1 Solution

Accepted Solutions
KenDoman
Occasional Contributor II
the JavaScript API provides methods to move the layers on the map. Here's an example, just replace the urls with something that works.

dojo.require("esri.map"); dojo.require("esri.layers.wms");  var map = new esri.Map("mapdiv");  // to initially set the layer order, create an array of layers var layerList = dojo.map(["base", "dog", "cat", "bird", "car"], function (urlEnding) { return new esri.layers.WMSLayer("http://wms-source/layer/" + urlEnding); });  map.addLayers(layerList); // map layer order: // ["base", "dog", "cat", "bird", "car"]  // now if you want to move a layer around, use map.reorderLayer var movingLayer = new esri.layers.WMSLayer("http://wms-source/layer/toMove"); map.addLayer(movingLayer); // map layer order: // ["base", "dog", "cat", "bird", "car", movingLayer]  map.reorderLayer(movingLayer, 2);  // second number is index of map layer where you want to move the layer. // index of 0 is base layer (bottom layer) // map layer order: // ["base", "dog", movingLayer, "cat", "bird", "car"] 


http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#reorderLayer

View solution in original post

0 Kudos
1 Reply
KenDoman
Occasional Contributor II
the JavaScript API provides methods to move the layers on the map. Here's an example, just replace the urls with something that works.

dojo.require("esri.map"); dojo.require("esri.layers.wms");  var map = new esri.Map("mapdiv");  // to initially set the layer order, create an array of layers var layerList = dojo.map(["base", "dog", "cat", "bird", "car"], function (urlEnding) { return new esri.layers.WMSLayer("http://wms-source/layer/" + urlEnding); });  map.addLayers(layerList); // map layer order: // ["base", "dog", "cat", "bird", "car"]  // now if you want to move a layer around, use map.reorderLayer var movingLayer = new esri.layers.WMSLayer("http://wms-source/layer/toMove"); map.addLayer(movingLayer); // map layer order: // ["base", "dog", "cat", "bird", "car", movingLayer]  map.reorderLayer(movingLayer, 2);  // second number is index of map layer where you want to move the layer. // index of 0 is base layer (bottom layer) // map layer order: // ["base", "dog", movingLayer, "cat", "bird", "car"] 


http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#reorderLayer
0 Kudos