Standard Esri Map Control

Display a Legend for a Reference Layer

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. It is often useful to display a legend for reference layers so users understand what the layer symbology means.

This example allows the user to toggle the display of a reference layer.

Add an action button for the reference layers to the map panel:

<action id="showLegend" type="menu" imageName="/schema/ab-core/graphics/icons/view/ab-arcgis-legend-16.png">
<title translatable="true">Legend</title>
</action>

Add an event handler for the legend button :

var legendObj = Ext.get(‘showLegend’);
legendObj.on(‘click’, mapController.showLegend, this, null)

When the legend button is clicked, call showEsriLegend() :

mapController.mapControl.showEsriLegend();

map.png

Note: The reference layer legend supports ArcGISTiledMapServiceLayer and ArcGISDynamicMapServiceLayer types for ArcGIS Server 10.0 SP1 or higher. For layers which are version 10 and lower, the map service must be publicly accessible for the legend to render.

Sample view: http://localhost:8080/archibus/ab-arcgis-bl-switch-layers.axvw