reordering a MapImageLayer

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

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 Emeritus

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 Emeritus

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
Occasional Contributor III

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 II

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
Occasional Contributor III

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

map.addLayer(myImgLayer, position);

0 Kudos