Select to view content in your preferred language

Cannot get featureLayer to display under DynamicMapServiceLayer

4516
4
Jump to solution
01-20-2012 05:38 AM
GarethMann
Deactivated User
I am trying to add 2 layers to my map, 1 featureLayer and 1 dynamicMapServiceLayer. The featureLayer needs to show up underneath the dynamicMapServiceLayer.

For some reason if I try to add the featurelayer first I get a "type error" in serverapi.arcgisonline.com:14:

TypeError
arguments: Array[2]
get message: function getter() { [native code] }
get stack: function getter() { [native code] }
set message: function setter() { [native code] }
set stack: function setter() { [native code] }
type: "non_object_property_load"
__proto__: Error


If I add the featureLayer in after adding the dynamicMapServiceLayer it works fine and I get no error. However I need the featureLayer to be under the dynamicMapServiceLayer not ontop. I have tried to add it to the map with an index of 0 (map.addLayer(featureLayer,0)) but it still puts it on top. I have tried to use "map.reorderLayer" but it does not seem to do anything, it still shows up on top. What am I doing wrong and why will the featureLayer not show up under the dynamicMapServiceLayer?

Here is my page:

http://northmiamicra.org/PWorksLayout.html
1 Solution

Accepted Solutions
StephenLead
Honored Contributor
If I add the featureLayer in after adding the dynamicMapServiceLayer it works fine and I get no error. if I try to add the featurelayer first I get a "type error"


I think the map is taking on the properties (such as extent and coordinate system) of the Dynamic layer, which then allows you to add the Feature Layer. See the Dynamic Map help entry which says: "If the first layer added to the map is an ArcGISDynamicMapServiceLayer, the map will take on the projection of this layer."

You could try specifying these properties when you declare the Map object:

//specify the initial extent and coordinate system
 var initExtent = new esri.geometry.Extent({"xmin":-9270392,"ymin":5247043,"xmax":-9269914,"ymax":5247401,"spatialReference":{"wkid":102100}});
//create map
map = new esri.Map("mapDiv",{extent:initExtent}); 


This should allow you to add the Feature layer to the map without first requiring the Dynamic layer.

What am I doing wrong and why will the featureLayer not show up under the dynamicMapServiceLayer?


A Feature layer is a type of Graphics layer, and according the help file, "Graphics layers can be reordered within the group of graphics layers. However, the graphics layer in Map.Graphics is always on top. Also, all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers."

So you may need to change the way you're adding these layers, and either use two Feature layers, or two Dynamic layers.

Steve

View solution in original post

4 Replies
GarethMann
Deactivated User
**bump bump**
0 Kudos
StephenLead
Honored Contributor
If I add the featureLayer in after adding the dynamicMapServiceLayer it works fine and I get no error. if I try to add the featurelayer first I get a "type error"


I think the map is taking on the properties (such as extent and coordinate system) of the Dynamic layer, which then allows you to add the Feature Layer. See the Dynamic Map help entry which says: "If the first layer added to the map is an ArcGISDynamicMapServiceLayer, the map will take on the projection of this layer."

You could try specifying these properties when you declare the Map object:

//specify the initial extent and coordinate system
 var initExtent = new esri.geometry.Extent({"xmin":-9270392,"ymin":5247043,"xmax":-9269914,"ymax":5247401,"spatialReference":{"wkid":102100}});
//create map
map = new esri.Map("mapDiv",{extent:initExtent}); 


This should allow you to add the Feature layer to the map without first requiring the Dynamic layer.

What am I doing wrong and why will the featureLayer not show up under the dynamicMapServiceLayer?


A Feature layer is a type of Graphics layer, and according the help file, "Graphics layers can be reordered within the group of graphics layers. However, the graphics layer in Map.Graphics is always on top. Also, all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers."

So you may need to change the way you're adding these layers, and either use two Feature layers, or two Dynamic layers.

Steve
MarcelKleinmann
Emerging Contributor

Also, all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers."

So you may need to change the way you're adding these layers, and either use two Feature layers, or two Dynamic layers.


Yes, I try to do the same. I need my ArcGISDynamicMapServiceLayer to be on top of my FeatureLayer, since I need the labels of the ArcGISDynamicMapServiceLayer on top. To make the FeatureLayer transparent by setting the opacity is not the right way, then the colors of the FeatureLayer are not the same any more!

I helped myself so far with another way of labeling, described here:

var textSymbol = new esri.symbol.TextSymbol("Here be dragons");
         textSymbol.setColor( new dojo.Color([128, 0, 0]));
         textSymbol.setAlign(esri.symbol.TextSymbol.ALIGN_START);
         textSymbol.setAngle(15);
         
         textSymbol.setFont(font);      
        
         var pt=  new esri.geometry.Point(x,y,map.spatialReference)
         var gra = new esri.Graphic(pt,textSymbol);      
         map.graphics.add(gra);


But this is not powerful enough for me, since there is no dynamical placement of labels anymore. Meaning the labels are fixed on one point on the map now! So you will find overlapping labels and label parts, cropped by the map border.

Is there any way to display labels from an arcgis javascript api layer with all their advantages on top of a FeatureLayer?

Please assist.
0 Kudos
GarethMann
Deactivated User

A Feature layer is a type of Graphics layer, and according the help file, "Graphics layers can be reordered within the group of graphics layers. However, the graphics layer in Map.Graphics is always on top. Also, all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers."

So you may need to change the way you're adding these layers, and either use two Feature layers, or two Dynamic layers.

Steve


Thanks steve, that has helped me a lot.