c_r_b

ArcGISDynamicMapServiceLayer always displays below FeatureLayers in same map

Discussion created by c_r_b on Apr 7, 2014
Latest reply on Apr 9, 2014 by kenbuja
When adding an ArcGISDynamicMapServiceLayer and several FeatureLayers to the same map in the JavaScript API, I want the ArcGISDynamicMapServiceLayer  to always display on top since it is a dedicated service for map labels.  However regardless of where I add this layer to the map using map.addLayer() -- whether it's added before or after several FeatureLayers -- the ArcGISDynamicMapServiceLayer is always rendered below the FeatureLayers, covering up my labels.

Is is possible to have the ArcGISDynamicMapServiceLayer always display on the top of the map?

Neither of these work:

var map = new Map("mapDiv", { ... }};
var labels = new ArcGISDynamicMapServiceLayer("http://URL_TO_Map_Service/Labels/MapServer");
var fl1 = new FeatureLayer("http://URL_TO_Map_Service/FS/MapServer/1";
var fl2 = new FeatureLayer("http://URL_TO_Map_Service/FS/MapServer/2";
map.addLayer(labels); /// <<<<<<<<<<
map.addLayers([fl1, fl2]);


NOR:

var map = new Map("mapDiv", { ... }};
var labels = new ArcGISDynamicMapServiceLayer("http://URL_TO_Map_Service/Labels/MapServer");
var fl1 = new FeatureLayer("http://URL_TO_Map_Service/FS/MapServer/1";
var fl2 = new FeatureLayer("http://URL_TO_Map_Service/FS/MapServer/2";
map.addLayers([fl1, fl2]);
map.addLayer(labels); /// <<<<<<<<<<


The labels are always displayed below the FeatureLayers.

Outcomes