function createBasemapGallery(){ var basemaps= []; var imageryLayer = new esri.dijit.BasemapLayer({ url:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" }); var imageryBasemap = new esri.dijit.Basemap({ layers:[imageryLayer], title:"Imagery", thumbnailUrl:"images/imageryThumb.jpg" }); basemaps.push(imageryBasemap); var boundariesLayer = new esri.dijit.BasemapLayer({ url:"http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer" }); var imageryBoundariesBasemap = new esri.dijit.Basemap({ layers:[boundariesLayer,imageryLayer], title:"Imagery (labels)", thumbnailUrl:"images/imagery_labelsThumb.jpg" }); basemaps.push(imageryBoundariesBasemap); var topographicLayer = new esri.dijit.BasemapLayer({ url:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" }); var topographicBasemap = new esri.dijit.Basemap({ layers:[topographicLayer], title:"Topographic", thumbnailUrl:"images/topographicThumb.jpg" }); basemaps.push(topographicBasemap); var streetLayer = new esri.dijit.BasemapLayer({ url:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" }); var streetBasemap = new esri.dijit.Basemap({ layers:[streetLayer], title:"Street Map", thumbnailUrl:"images/streetThumb.jpg" }); basemaps.push(streetBasemap); var terrainLayer = new esri.dijit.BasemapLayer({ url:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer" }); var terrainBasemap = new esri.dijit.Basemap({ layers:[terrainLayer], title:"Terrain Map", thumbnailUrl:"images/terrainThumb.jpg" }); basemaps.push(terrainBasemap); var noneLayer = new esri.dijit.BasemapLayer({ url:"http://" }); var noneBasemap = new esri.dijit.Basemap({ layers:[noneLayer], title:"None", thumbnailUrl:"images/noneThumb.jpg" }); basemaps.push(noneBasemap); var basemapGallery = new esri.dijit.BasemapGallery({ showArcGISBasemaps:false, basemaps:basemaps, map:map },"basemapGallery"); basemapGallery.startup(); dojo.connect(basemapGallery, "onError", function(error) {console.log(error)}); }
hideBaseMap: function(){ var _this = this; dojo.forEach(this.map.layerIds, function(id){ var layer = _this.map.getLayer(id); if (layer._basemapGalleryLayerType === "basemap") { layer.hide() } }); }
Hi,
I want to customize my basemap gallery. I want to remove streets and streets and openstreetmap from the gallery, all the remaining basemaps are still there in the gallery.
I tried using BasemapGallery | API Reference | ArcGIS API for JavaScript the function
function removeBasemap(id){
basemapGallery.remove(id);
}
and also just basemapGallery.remove(galleryNode_basemap_7) as shown in the bellow image;
But dint work. can someone help me in removing those two basemaps from the basemap gallery.
Thanks in advance.
You'll need to wait for the basemap to load before using the 'remove' function.
basemapGallery.on('load',function(){ basemapGallery.remove('basemap_2'); basemapGallery.remove('basemap_9'); }); basemapGallery.startup();