Switch Basemap Layers
Standard Esri Map Control
Switch Basemap Layers
Technologies > User Interface Add-Ins > Geographic Information System (GIS) Views > Map with Basemap Selector
A series of basemap and reference layers are made available through ArcGIS Online. Basemap options include imagery, streets, and topographic maps. In this example the user is able switch basemap layers from a dropdown menu of available options.
Add an action button for the basemap layers to the map panel:
<action id="basemapLayerMenu" type="menu" imageName="/schema/ab-core/graphics/icons/view/ab-arcgis-basemap-16.png">
<title translatable="true">Basemaps</title>
</action>
To build the dropdown menu, first retrieve the list of layers using
getBasemapLayerList()
::
var basemapLayers = mapController.mapControl.getBasemapLayerList();
Create a menu item, action, and event handler for each basemap layer :
var basemapLayerMenu = mapController.mapPanel.actions.get('basemapLayerMenu'); for (var i=0; i<basemapLayers.length; i++) { basemapLayerMenu.addAction(i, basemapLayers[i], this.switchBasemapLayer); }
When a menu item is selected, pass the selected item to the menu item's event handler and call
switchBasemapLayer()
:
mapController.mapControl.switchBasemapLayer(item.text);
Sample view: http://localhost:8080/archibus/ab-arcgis-bl-switch-layers.axvw