The goal is to save the state of a basemap from the basemap gallery, then re-render it later. I have done this sucesfully with all my basemap using the below portalItem.id
however there are a few basemaps with null
portalItem
object (i.e. no portalItem.id (arcgis 4.x)
basemapGallery.activeBasemap = {portalItem: {id: "588f0e0acc514c11bc7c898fed9fc651"}};
i.e.
baseLayers: (...)id: (...)load: ƒ ()loadError: (...)loadStatus: (...)loadWarnings: (...)loaded: (...)**portalItem: null**
Is there anything I could do to create some-type of handler so I can save my selection of these maps as well, then re-render later as I am doing with the others?
I have tried setting a portalItem
in the below format, but still fails. Anything I could here?
if (newBasemap.id === 'shaded_relief_light') { } else if (newBasemap.id === 'shaded_relief_dark') { } else if (newBasemap.id === 'world_nav_charts') { } else if (newBasemap.id === 'skyvector_hi_map') { } else if (newBasemap.id === 'skyvector_lo_map') { } if (newBasemap.id === 'skyvector_vfr_map') { }
I have also tried generating ones for those few that do not have them.
if (myCoolApp.widgets.basemapManager.basemapGallery.activeBasemap.portalItem) { basemapSaved = myCoolApp.widgets.basemapManager.basemapGallery.activeBasemap.portalItem.id; coolGuy.baseMapId = basemapSaved; } else { let r = Math.random().toString(36).substring(7); myCoolApp.widgets.basemapManager.basemapGallery.activeBasemap.portalItem.id = r console.log(r); }