Reorder Graphics Layers Between Other Layers

2358
6
Jump to solution
03-24-2016 06:48 AM
DavidChevrier
Occasional Contributor II

Hi,

    I have a simple map.  It includes the ocean basemap (and ocean label reference layer automatically), then I add an ArcGISTiledMapServiceLayer that is hosted on my ArcGIS for Server.  When the user presses a button, it runs a geoprocessing service (also on my ArcGIS for Server).   I add the returned features to a featureset, which is added to a featureCollection and used to create a new featureLayer.  This featureLayer is given a renderer and added to the map.  It works fine, however it seems to add this featureLayer to the graphics layer of the map.  Since graphics layers are always on top, I cant order the layers how I want.  Basically, I need the layers to be (from bottom to top); ocean basemap, geoprocessing result, ArcGISTiledMapServiceLayer, and ocean labels.  Is there a way to do this?   It looks like I might be able to in the beta, but am using version 3.16.

Thanks

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

David,

  No this is not possible in the 3.x version of the API as FeatureLayer inherits from GraphicsLayer and GraphicsLayers are always drawn on top.

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 andDynamicMapServiceLayers.

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Emeritus

David,

  No this is not possible in the 3.x version of the API as FeatureLayer inherits from GraphicsLayer and GraphicsLayers are always drawn on top.

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 andDynamicMapServiceLayers.

DavidChevrier
Occasional Contributor II

Good to know, thanks.  So in 4.x, you can reorder the layers this way?  I'd rather not convert to 4 until it is out of beta however.  Although I don't know when that will be.  And converting to 4 will be a major rewrite of a lot of code, correct? 

0 Kudos
DavidChevrier
Occasional Contributor II

I should also say that I'm (reluctantly) coming over to the javascript api from silverlight.  I really loved developing in silverlight with xaml and c# in visual studio and am finding the javascript api to require a little more code to do similar functions.   Also a little more clunky and less elegant.    But I know esri is putting more time, effort and money into javascript and it is nice to not require a plug in.  It just a bit more of a learning curve than I was expecting.  But its the ide I miss the most, the WYSIWYG ability and ease of use debugging tools in VS were great.   Oh, and binding...  I really miss that.... I've heard you can do it in javascript with additional tools, but haven't figured that out yet.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

David,

     I have not done a bunch with 4.0 yet but yes it is suppose to be possible. 4.0 final should hit around UC time. Yes a lot has change in the coding with the separation of models and views.

I came to the JS api from Flex and Flash Builder so I am familiar with the LOE involved in learning a new language but I am getting very comfortable in JS using IDEs like Brackets and Atom. Initially I was hung up on have intelli-sense and autocomplete but I quickly got past this and am happy coding in JS.

DavidChevrier
Occasional Contributor II

I'm still using visual studio, but with a php plug in.  Technically I'm writing a php as I need to perform simple sql queries to oracle and found this as the only way to do it easily.  Good to know that it gets better lol.  Thanks for your help today and yesterday on another post I wrote!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

David,

  Sure thing. Don't forget to mark this as answered.

0 Kudos