Skip to content
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

L.esri.featureLayer's maxZoom/minZoom #1399

Open
shawnmgoulet opened this issue Feb 3, 2025 · 3 comments
Open

L.esri.featureLayer's maxZoom/minZoom #1399

shawnmgoulet opened this issue Feb 3, 2025 · 3 comments
Assignees

Comments

@shawnmgoulet
Copy link

Describe the bug

In this sample, a maxZoom and minZoom are set on a L.esri.featureLayer. The issue is that, after the initial zoom into and out of the maxZoom/minZoom range, the L.icons do not disappear and remain on the map.

Image

Reproduction

A repro Codepen is available here: https://codepen.io/shawnmgoulet/pen/xbKNwrM.

  1. Add Leaflet esri-leaflet via CDN
  2. Add a L.esri.featureLayer using a point feature service, with maxZoom and minZoom properties and a pointToLayer function that returns an L.marker using a L.icon to represent point features.
  3. Zoom to within the maxZoom and minZoom zoom levels, back out of the range, then back into the range and back out again. At this point, you will see L.icons still visible on the map.

Logs

System Info

Leaflet version: 1.9.4 | Esri Leaflet version: 3.0.13

Additional Information

No response

@gavinr-maps
Copy link
Contributor

Thanks for logging this @shawnmgoulet. I am seeing the issue in your example Codepen, but I created a simple sample with the USA Cities service, and I cannot get the issue to happen here: https://jsbin.com/gimaxag/1/edit?html,output

I'll do some more research to try to see what specifically is causing this issue.

@gavinr-maps
Copy link
Contributor

I have validated that this issue happens even without the image symbol or the popups. Here's the simplest replication case I can find:

https://jsbin.com/wotodul/1/edit?html,output

  1. Click the zoom-in button 4 times
  2. After the points start loading, click the zoom out button
    • Expected: No points showing on the map
    • Actual: sometimes some of the points are still showing on the map: Image

This seems to happen with feature services with lots of points, and does not happen on feature services with few points. Because of this, my current hypothesis is that if you zoom out so Esri Leaflet tries to hide the layer as they layer is still loading, sometimes the layer will not get hidden properly. Services with lots of data take longer to load so it's easier to get into this situation in situations with lots of data. I need to jump into the code to try to validate this.

@gavinr-maps gavinr-maps self-assigned this Feb 5, 2025
@gavinr-maps
Copy link
Contributor

gavinr-maps commented Feb 5, 2025

If I remove this code:

for (var i in this._cells) {
var coords = this._cells[i].coords;
var key = this._cacheKey(coords);
if (this._cache[key]) {
this.addLayers(this._cache[key]);
}
}

... the issue does not happen. I am not saying this is the solution to the bug since removing that code probably causes issues with other things, but it's a good data point on the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants