Switch Reference Layers
Standard Esri Map Control
Switch Reference 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. Reference layer options include a series of USA demographic layers. In this example the user is able switch reference layers from a drop-down menu of available options.
Add an action button for the reference layers to the map panel:
<action id="referenceLayerMenu" type="menu" imageName="/schema/ab-core/graphics/icons/view/ab-arcgis-layers-16.png">
<title translatable="true">Layers</title>
</action>
To build the drop-down menu, first retrieve the list of available reference layers using
getReferenceLayerList()
:
var referenceLayers = mapController.mapControl.getReferenceLayerList();
Create a menu item, action, and event handler for each reference layer :
var referenceLayerMenu = mapController.mapPanel.actions.get('referenceLayerMenu');
for (var i=0; i<referenceLayers.length; i++) {
referenceLayerMenu.addAction(i, referenceLayers[i], this.switchReferenceLayer);
}
When a menu item is selected, pass the selected item to the menu item's event handler and call
switchReferenceLayer()
:
mapController.mapControl.switchReferenceLayer(item.text);
Sample view: http://localhost:8080/archibus/ab-arcgis-bl-switch-layers.axvw