Map switcher widget
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.
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.
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.
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.
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
- Reads Viewer application configuration file and finds
all layers:
- For basemaps, it creates a unique button control in the Viewer UI for each basemap.
- For operational layers, it lists them under the More ... button.
- Operational layers can optionally be excluded from the widget display.
- Basemaps with the same label will be grouped together under one button.
Test drive the Map Switcher widget or see its tag reference.