reordering a MapImageLayer

958
5
09-19-2016 02:10 PM
MarcBate
Occasional Contributor

In JSAPI 3.17, reordering a MapImageLayer seems to have no effect.  I am calling map.reorderLayer(mapImageLayer,layerOrder)  where layerOrder is a number and mapImageLayer is a MapImageLayer | API Reference | ArcGIS API for JavaScript 3.17 

It always wants to put the layer at position 1 right above the basemap.

Any workarounds?

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Marc,

   The way the JS API 3.x is built layer order is confined to this order

  1. Basemap
  2. MapImageLayers, TiledMapServices, DynamicMapServices
  3. FeatureLayers and GraphicsLayers
  4. Map graphics layer

I thought I could find a reference to this somewhere in the API Docs but I cant seem to now.

This is based on the internal workings of the API and the fact that graphics and featurelayers are drawn using SVG verses basemap, tiled, dynamic use a image returned from the server.

RebeccaStrauch__GISP
MVP Esteemed Contributor

I seem to recall someone having a semi workaround (maybe you Robert?), or more of a trick. 

Create a custom basemap that basically has nothing on it or is very transparent.  Then use you layer.  If you need the "basemap" features on top, just have it as another tiled layer.

This is untested by me, so no other suggestions.

thejuskambi
Regular Contributor

Yes, you can do that with Basemap and BasemapLayer. By setting the isReference = true will make the layer to be visible on top of all the other layers. checkout the constructor parameters for BasemapLayer

BasemapLayer | API Reference | ArcGIS API for JavaScript 3.17 

Set to true if the layer is a reference layer and should be drawn on top of all other layers in the map.

MarcBate
Occasional Contributor

I've created a dialog for reordering layers, and guess I will need to disable MapImageLayers if they can't be reordered.

0 Kudos
EvelynHernandez
Regular Contributor

Why u dont try adding the mapimagelayer as a normal layer with:

map.addLayer(myImgLayer, position);

0 Kudos