Solved! Go to Solution.
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"]
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"]