Esri / esri-leaflet

A lightweight set of tools for working with ArcGIS services in Leaflet. :rocket:
https://developers.arcgis.com/esri-leaflet/
Apache License 2.0
1.61k stars 799 forks source link

addfeature event is not firing for layers with min zoom #1297

Closed main-kun closed 3 years ago

main-kun commented 3 years ago

Describe the bug

I'm trying to add feature labeling to a layer with minZoom option following the docs example: https://esri.github.io/esri-leaflet/examples/labeling-features.html When the zoom level decreases, removefeature event fires as expected and the labels are removed together with the markers. When zoom is increased again, markers come back but addfeature event does not fire so labels cannot be added back to the map.

Expected behavior

Actual behavior

To Reproduce

Please share and fill in the steps below to reproduce the behavior.

THIS IS REQUIRED - If you do not provide the steps for others to reproduce the issue you're seeing, it is impossible for them to assist you. Please create a jsbin that demonstrates the problem and include the steps to see the issue:

Example

  1. Go to the map
  2. Zoom out
  3. Zoom back in
  4. See that there is no console.log for the addfeature event and the labels are not brought back

Screenshots

If applicable, add screenshots to help explain your problem.

Environment Information

Additional context

Add any other context about the problem here. If you're are not using the CDN, please note what loading/bundling library you are using (webpack, browserify, RequireJS)?

gavinr commented 3 years ago

Thank you for the report. I've tested your jsbin on different versions of Esri Leaflet. From what I can tell, it seems like the bug you're describing started at v2.4.0. (In other words, if you change the script tag in your jsbin to <script src="https://unpkg.com/esri-leaflet@2.3.3/dist/esri-leaflet.js"></script> it works fine).

In that release (v2.4.0), the only change related to Feature Layer was #1189, so I suspect this bug has to do with that change.

gavinr commented 3 years ago

I think there may be something unexpected happening with the "removefeature" event too. For example, in your jsbin, if youzoom out once, and then zoom out a few more times, the removefeature event still gets called (expected: should only be called once when the features went invisible).

gavinr commented 3 years ago

I've created a more general issue report to replace this one with a few more specifics on what I've found: #1298. Please follow that for updates.