New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SubLayers of L.Esri.DynamicMapLayer get recreated and assigned new leaflet id on add/remove #1046
Comments
Hello, Not sure this is an issue but rather an expected behavior as layer id gets incremented when adding new layers. |
I've always used map.add/removeLayer() to change visibility in leaflet. Is there a different way? What do you mean by set to not visible? Does this avoid requesting the info from the server (I don't want to request a bunch of rasters and then 'hide' them with an opacity of 0) |
For a dynamicMapLayer, you can use setLayers with an empty array: |
While that does work, it doesn't change the unexpected change of layerId. Even if I use setLayers to add/remove sublayers, they are assigned a new layerId. With setLayers, I can understand that a new layerId would be created (since it's hard to predict when switching from [0] to [1,2,] to [0] for example that you are going back to a previously made layer). Underneath everything it probably is just adding/removing/recreating the layers as usual. Based on the way other leaflet layers work, when adding/removing a specific layer it should be added back in the same state it was removed, so the expected behavior for removing then adding a parent layer is that its child layers retain their original ids as well. |
@ahalota do you still find that this statement is still true in the most recent version of esri-leaflet?
If so, can you please create and share a public demo that we can use to investigate and discuss further? |
This was a while ago, but I'll see if I can take a look later this week...
…On Tue, Nov 17, 2020, 10:34 AM Jacob Wasilkowski ***@***.***> wrote:
@ahalota <https://github.com/ahalota> do you still find that this
statement is still true in the most recent version of esri-leaflet?
This creates a big issue if attempting to attach any handlers to the
subLayer, since it is recreated.
If so, can you please create and share a public demo that we can use to
investigate and discuss further?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1046 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXLX76CMCE6PE2WLOU4APLSQKJYZANCNFSM4EQBBNHA>
.
|
Thanks for your interest and patience! I'd like to dust it off and give it a fresh pair of eyes. |
This issue has been automatically marked as stale because we're waiting on more information or details, but have not received any response. It will be closed if no further activity occurs. Thank you! |
L.version
):1.3.1
L.esri.VERSION
):2.1.2
Steps to reproduce the error:
myLayer = L.esri.dynamicMapLayer({ url: layerUrl, layers: [0]}).addTo(map)
map._layers >> {32: NewClass, 33: NewClass, 70: NewClass, 85: NewClass, 163: NewClass}
In my case, 70 is the esriLayer, and 163 is the layer for [0]
map.removeLayer(myLayer)
map._layers >> {32: NewClass, 33: NewClass, 85: NewClass}
map.addLayer(myLayer)
map._layers >> {32: NewClass, 33: NewClass, 70: NewClass, 85: NewClass, 172: NewClass}
You can see that the subLayer [0] has a new id, 172, instead of the previous 163.
This creates a big issue if attempting to attach any handlers to the subLayer, since it is recreated.
The text was updated successfully, but these errors were encountered: