You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have code like this that lets you switch between ESRI basemaps and also shows some features:
var m = L.map('map').setView([45.5275, -122.6717], 14);
var esriImagery = L.esri.basemapLayer("Imagery");
var esriTopo = L.esri.basemapLayer("Topographic");
var lc = L.control.layers({
"ESRI Imagery": esriImagery,
"ESRI Topographic": esriTopo,
}).addTo(m);
esriImagery.addTo(m);
var bikePaths = L.esri.featureLayer({url: 'https://services.arcgis.com/uCXeTVveQzP4IIcx/ArcGIS/rest/services/Bike_Routes/FeatureServer/0'}).addTo(m);
While it's still on the Imagery basemap, everything works fine. But switch to the Topographic basemap and zoom in and out repeatedly, and the feature layers will end up completely out of place.
As far as I can tell the issue is caused by line 216 of Basemap.js, in the onRemove function: map.off('moveend', this._updateMapAttribution, this);
When I remove that line from my local copy, the issue is resolved. But I don't understand why it would affect feature layers.
Another workaround is to use TileLayers based on the basemaps but with static attributions:
apparently i introduced _two_ bugs when i refactored dynamic attribution logic into the generic L.esri.Util utility class. thank you for helping me identify both and my sincere apologies for the inconvenience.
the problem is that we are currently not unwiring the same event listener for interrogating and displaying attribution when a basemapLayer is removed that we appended when the layer was first added.
onAdd: function(map){map.on('moveend',Util._updateMapAttribution);
onRemove: function(map){// this refers to the layer itself, not the function housed within L.esri.Utilmap.off('moveend',this._updateMapAttribution,this);
if anyone is curious why i wanted to move that code out of basemapLayer to begin with, its because i'm in the middle of writing another plugin to load esri vector tiles in leaflet and i thought it made sense to reuse the same code to handle attribution updates as people pan and zoom around the map.
I have code like this that lets you switch between ESRI basemaps and also shows some features:
While it's still on the Imagery basemap, everything works fine. But switch to the Topographic basemap and zoom in and out repeatedly, and the feature layers will end up completely out of place.
As far as I can tell the issue is caused by line 216 of Basemap.js, in the onRemove function:
map.off('moveend', this._updateMapAttribution, this);
When I remove that line from my local copy, the issue is resolved. But I don't understand why it would affect feature layers.
Another workaround is to use TileLayers based on the basemaps but with static attributions:
The text was updated successfully, but these errors were encountered: