I'm working on a web app that has multiple mapviews, built on node (so not using CDN). We have one primary map that has a basemap selector, and I'd like to propagate the basemap that one is using to others. As the user moves around the app, there are instances where maps are destroyed and removed from the page, and I'd prefer to just recreate new resources rather than have to write code for each to remove things like the basemap before calling .destroy().
---------------------
// ESRI basemap is so nice...
const defaultBasemap = new Basemap({
style: new BasemapStyle({
id: "arcgis/topographic",
worldview: "unitedStatesOfAmerica"
})
});
/** The BasemapController class is used to handle updating all map basemaps and change them all when the main map one is changed. */
export class BasemapController {
/** The current basemap in use. */
static _currentBasemap : Basemap;
/** Returns the current basemap. Unless the user chooses a different one, this will be the DefaultBasemap(). */
static GetCurrentBasemap() : Basemap {
if (this._currentBasemap == null) {
this._currentBasemap = this._getDefaultBasemap();
}
// Return clone so if it is destroyed it doesn't blow up the rest
let clone = this._currentBasemap.clone(); // Invoking .clone() makes the returned one not draw
return clone;
}
====================
// Usage:
this.mainMap= new Map({
basemap: BasemapController.GetCurrentBasemap()
});
====================
I don't understand why this occurring. Is this a bug in the SDK? I see nothing in the output on the console.