Arcgis api for flex Development (3) Use of Map Browsing controls
Map Browsing includes enlarging, downgrading, roaming, resetting, upper-level windows, and lower-level windows.
In arcgis api for flex, esri has encapsulated a map view.
It can be used directly and requires dozens of lines of code to complete complex tasks.
First, create a Navigation control based on the previous lecture. Use the <esri: Navigation> label
You can.
<Esri: Navigation id = "navToolbar" map = "{myMap}"/>
Set the map attribute of the <esri: Navigation> label to the map to be controlled, that is, bind the control
Map.
Then we create a toolbar to control map browsing.
<Mx: ControlBar horiz paddingBottom = "0" paddingTop = "0">
<Mx: Button label = "zoom in" click = "navToolbar. activate
(Navigation. ZOOM_IN) "/>
<Mx: Button label = "zoom out" click = "navToolbar. activate
(Navigation. ZOOM_OUT) "/>
<Mx: Button label = "Roaming" click = "navToolbar. activate
(Navigation. PAN) "/>
<Mx: Button label = "upper-level window" click = "navToolbar. zoomToPrevExtent
() "Enabled = "{! NavToolbar. isFirstExtent} "/>
<Mx: Button label = "lower-level window"
Click = "navToolbar. zoomToNextExtent ()" enabled = "{!
NavToolbar. isLastExtent} "/>
<Mx: Button label = "reset" click = "navToolbar. zoomToFullExtent ()"/>
The click message response function of the button directly calls the <esri: Navigation> control function.
. Zoom in and zoom out. roaming calls functions of the activation tool. Response Functions of the remaining three buttons
Call the <esri: Navigation> Control zoomToPrevExtent, zoomToNextExtent,
The zoomToFullExtent function is OK.
Code
<? Xml version = "1.0" encoding = "UTF-8"?>
<Mx: Application
Xmlns: mx = "http://www.adobe.com/2006/mxml"
Xmlns: esri = "http://www.esri.com/2008/ags"
PageTitle = "Using ArcGIS API for Flex to connect to a cached ArcGIS
Online service"
StyleName = "plain">
<Esri: Navigation id = "navToolbar" map = "{myMap}"/>
<Esri: SpatialReference id = "sr" wkid = "4326" type = "codeph" text = "codeph"/>
<Mx: ControlBar horizontalGap = "0" paddingBottom = "0" paddingTop = "0">
<Mx: Button label = "zoom in" click = "navToolbar. activate
(Navigation. ZOOM_IN) "/>
<Mx: Button label = "zoom out" click = "navToolbar. activate
(Navigation. ZOOM_OUT) "/>
<Mx: Button label = "Roaming" click = "navToolbar. activate
(Navigation. PAN) "/>
<Mx: Button label = "upper-level window" click = "navToolbar. zoomToPrevExtent
() "Enabled = "{! NavToolbar. isFirstExtent} "/>
<Mx: Button label = "lower-level window"
Click = "navToolbar. zoomToNextExtent ()" enabled = "{!
NavToolbar. isLastExtent} "/>
<Mx: Button label = "reset" click = "navToolbar. zoomToFullExtent ()"/>
</Mx: ControlBar>
<Esri: Map crosshairVisible = "true" id = "myMap">
<Esri: extent>
<Esri: Extent id = "esriMapExtent" X min = "116"
Ymin = "39.5" xmax = "116.5" ymax = "40.5"/>
</Esri: extent>
<Esri: ArcGISTiledMapServiceLayer
Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap
_ World_2D/MapServer "/>
<Esri: GraphicsLayer id = "myGraphicsLayer"
SpatialReference = "{sr}"/>
</Esri: Map>
</Mx: Application>
Original address: http://bbs.esrichina-bj.cn/ESRI/viewthread.php? Tid = 35575 & extra = page % 3D4% 26amp % 3 Borderby % 3 Ddateline