Hi
I want to check if the basemap is change by another widget. I see that it exist an event on the esri map object but I didn't know how to connect it.
I search one on webappbuilder but I don't find. Does it exist?
Thanks.
Guillaume Arnaud
Fine,
I finally check "layer-add" event of map objet.
//Stocke les Basemaps dans une variable pour check le changement this.bms = ls.getBasemapLayerObjects();//Surveille l'évenement d'ajout de couche this.map.on("layer-add", lang.hitch(this, function() { //Si le(s) basemaps son modifiées if (this.bms != ls.getBasemapLayerObjects()){ //Stocke les Basemaps dans une variable pour check le changement this.bms = ls.getBasemapLayerObjects(); //Parcours les Basemaps this.bms.forEach(lang.hitch(this, this.fct_Add_Basemap)); } }));
//Stocke les Basemaps dans une variable pour check le changement this.bms = ls.getBasemapLayerObjects();
//Surveille l'évenement d'ajout de couche this.map.on("layer-add", lang.hitch(this, function() { //Si le(s) basemaps son modifiées if (this.bms != ls.getBasemapLayerObjects()){ //Stocke les Basemaps dans une variable pour check le changement this.bms = ls.getBasemapLayerObjects(); //Parcours les Basemaps this.bms.forEach(lang.hitch(this, this.fct_Add_Basemap)); } }));
It works.
You're correct. That event isn't fired when the Basemap Gallery is used. You have to listen to the Basemap Gallery's 'selection-change' event. https://community.esri.com/message/84178 This means you'd have to get the Gallery from the Basemap widget and listen for the change.
Sure, I try this :
dojo.connect(this.map, "onBasemapChange", lang.hitch(this, function(a) { console.log("connect"); console.log(a); }));
and this :
this.map.on("basemap-change", lang.hitch(this, function(a) { console.log("on"); console.log(a); }));
but it doesn't work. I don't know how to connect these 2 events because it's ok with other event like click or extent-change.
I change basemap with eBaseMapGallery or BaseMapGallery widget of WebAppBuilder
Thanks
You can gain access to the map simply with "this.map" within your widget.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.