Change layer order in LayerList without changing drawing order in the mapview

754
5
09-28-2023 01:04 PM
Status: Open
Nicolas_
New Contributor III

Is it possible to change the layer order in the LayerList widget without changing the drawing order in the mapview?

 

I tried using the layerList.viewModel.moveListItem() method, but the mapview is updated to reflect the layerList order.

 

NOTE: JS api 4.x

5 Comments
Sage_Wall

The LayerList is designed to reflect the order of the layers in the map.  In part for when `selectionEnabled` is true users can modify the layer order in the map.  I'm curious as to your use case for having them be different?

Nicolas_

I use the layerList with selection disabled.

Here is my use case. I have my layers ordered like so:

  • Basemap reference layers
  • Point feature layer 1
  • Point feature layer 2
  • ..
  • "reference layers" for my imagery layers (Hidden)
  • Imagery layer 1
  • Imagery layer 2
  • ..
  • Basemap

This way, I can display a map like this, with a hidden water layer over my imagery layers: 

Nicolas__0-1695991947357.png

This work great, but I woud like to be able to group "Point feature layer 1" with Imagery layer 1" and so on because they are actually related. But If I do that, I end up with my Point layers hidden behind the water features:

Nicolas__1-1695992182093.png

 

Maybe there is a way to unsuscribe to some kind of layerList layerMoved event?. Else I might have to directly modify the DOM.

Sage_Wall

Sorry @Nicolas_ there isn't anything currently in the API for this, but I think it's a valid use case.  I'd like to move this over to ArcGIS Ideas because it could be a great future addition to the JavaScript Maps SDK.  The best possible workaround I can see is to duplicate the hidden water layer into each imagery + point group layer, but it's less than ideal to have to add multiple copies of the same layer.

Nicolas_

Understood.

Thank you for moving this to ArcGIS Ideas. I will keep an eye on futur API releases.

AddisonShaw

I wrote my own layer list mimicking the behavior of the original, except it uses locally predefined definition expressions