Esri / esri-leaflet-vector

Display ArcGIS Online vector basemaps w/ Esri Leaflet
Apache License 2.0
56 stars 57 forks source link

Esri Attribution not removed when layer is removed #136

Closed tobwen closed 11 months ago

tobwen commented 2 years ago

Describe the bug

When displaying an ESRI Leaflet Vector layers, map.attributionControl._esriAttributionLayerCount always gets increased by 1, but it never gets decreased. This has the side-effect that the dynamic attribution doesn't disappear when there's no ESRI layer visible at all (and might lead to an overflow when a user or a script hits MAX_INTEGER).

Reproduction

https://jsbin.com/gaqaloguva/edit?html,console,output

  1. Since this only affects https://github.com/Esri/esri-leaflet-vector/ layers, you need to add your API key.
  2. When you switch between imagery 1 and imagery 2 you can see that the counter in console always increases. But it should stay at 1 in this case.

Logs

No response

System Info

Leaflet version 1.7.1, ESRI Leaflet version: v3.0.4, ESRI Leaflet Vector v3.1.1

Additional Information

I've published this in esri-leaflet-core, since https://github.com/Esri/esri-leaflet-vector/ doesn't contain attribution control.

gavinr commented 2 years ago

Thanks for the report. I agree that this is an issue. Here is another similar demo case:

https://jsbin.com/liriren/4/edit?html,output

  1. Click "Add basemap"
  2. Click "Remove Basemap"
    • Expected: "Powered by esri" attribution is removed
    • Actual: "Powered by esri" attribution is removed
  3. Click "Add Vector Tile Basemap"
  4. Click "Remove Vector Tile Basemap"
    • Expected: same as above, "Powered by esri" attribution is removed
    • Actual: the "Powered by esri" attribution is NOT removed