//make a flag so that we only pull out the second basemap layer the first time its changed var isFirst = true; ... basemapGallery.on("selection-change", function() { if (isFirst) { //check to make sure that the first basemap shown actually displayed two different tiled layers if (basemapGallery.getSelected().title == "Imagery with Labels" || basemapGallery.getSelected().title != "Light Gray Canvas" || basemapGallery.getSelected().title != "Terrain with Labels") { map.removeLayer(map.getLayer(map.layerIds[1])); //set the flag to false so none of this code fires again isFirst = false; } } });
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.