We have set showAttribution to true while creating map object and the attribution changes properly until we handle map.onLayerAdd and map.onLayerRemove Events.
As soon as we handel map.onLayerAdd and map.onLayerRemove Events Map Attribution is not working properly.
Steps to reproduce:
Sumit,
In order to listen for the layer add and remove events you should be doing something like this:
map.on("layer-add", function(layer){ console.log("Layer added - " + layer.id); }); map.on("layer-remove", function(layer){ console.log("Layer removed - " + layer.id); });
I switched out your existing code that set map.onLayerAdd and map.onLayerRemove to the above and the attribution works as expected.
Kelly Hutchins
We are facing same of problem of attribution not getting updated on basemap change if we create a map using any webmap which having “National Geographic word map” as a basemap.
Please Suggest.
When working with the JSAPI you want to use dojo/on to handle events. More details can be found here:
Working with events | Guide | ArcGIS API for JavaScript
Thanks kelly !
It work as expected now.
May I know what is the difference between this two different implementation, its Just for the information.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.