Map switcher widget

This page describes an older version, please read about the latest version at:
http://resources.arcgis.com/en/help/flex-viewer/concepts/

The Map Switcher widget primarily enables end users to easily switch between base maps in the Viewer application. Typically, base maps are used in the Viewer to display background imagery and street data. In the default configuration the widget is located at the upper right corner of the Viewer UI, underneath the HeaderController widget.

It retrieves all the base map layers that are specified in the Viewer application's configuration file contained within the <basemaps> tag and creates a UI button control for each layer. The config.xml file code sample below has three base maps:

...
<map>
    <basemaps>
        <layer label="Streets" type="tiled" visible="true" alpha="1"
                  url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
        <layer label="Aerial" type="tiled" visible="false" alpha="1"
                  url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
        <layer label="Topo" type="tiled" visible="false" alpha="1"
                  url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
    </basemaps>
...

It this case, the Map Switcher widget will have three UI button control base map options: Streets, Aerial, and Topo. The UI button controls are labeled based on the label attribute of the <layer> tag. Only one base map is visible at a time. Clicking one of the Map Switcher's UI buttons will change the base map displayed in the Viewer.

Screenshot of Map Switcher with basemap buttons

This widget also has an option to provide end-users the ability to turn on/off operational layers on the map display (if there any are available in the Viewer application's main configuration file). Operation layers are defined by <layer> tags that are contained within an <operationlayer> tag. When there is at least one operational layer, this functionality can be enabled and a More... button is added to the immediate left of Map Switcher widget.

Screenshot of the Map Switcher widget

Clicking the More... button will reveal a dropdown list of all available operational layers. Each has a checkbox that allows end users to easily turn their visibility on or off in the map display. The initial visibility for each operational layer is specified in the Viewer application's main configuration file.

Screenshot of the Map Switcher widget with the layer list open.

Since the Map Switcher widget is intended to be part of the Viewer UI, its <widget> tag would be referenced as an independent widget in the Viewer application configuration file, and not within a widget container.

TipTip:

With respect to displaying operational layers, this widget offers similiar functionality found in the Layer List widget. When designing the Viewer's capability to control the display of operational layers, it is recommended to use either the Map Switcher widget "More..." button OR the Layer List widget for a Web mapping application. It is not a best practice to have both enabled within the same Web mapping application. To not display the "More...", set the visible property on the layerlist tag:

<layerlist visible="false"/>

Conceptual Workflow

Requires: basemaps and operational layers

Test drive the Map Switcher widget or see its tag reference.

2/15/2012