Select to view content in your preferred language

ArcGISDynamicMapServiceLayer always displays below FeatureLayers in same map

2317
3
04-07-2014 09:01 AM
ChrisBeaudette
Frequent Contributor
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.
0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
FeatureLayer is inherited from GraphicsLayer. From the help information

all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers.
0 Kudos
ChrisBeaudette
Frequent Contributor
FeatureLayer is inherited from GraphicsLayer. From the help information


Doh!  Should've caught that.  Thanks for answering so quickly.
0 Kudos
KenBuja
MVP Esteemed Contributor
Glad to help. Don't forget to click the check to mark the question as answered. This will help others in searching on this topic.
0 Kudos