<!-- 監聽地圖的鼠標移動事件,顯示鼠標位置的座標值 -->
<!-- Copyright (c) 2010-2011 《ArcGIS Server開發指南——基於Flex和.NET》練習代碼
完整的代碼工程可以從 http://www.geocommon.net 下載 -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="455" minHeight="300" xmlns:esri="http://www.esri.com/2008/ags">
<fx:Script>
<![CDATA[
protected function mouseMoveHandler(event:MouseEvent):void
{
var lon:Number = map.toMapFromStage(event.stageX,event.stageY).x;
var lat:Number = map.toMapFromStage(event.stageX,event.stageY).y;
labelX.text = "X: " + numFormater.format(lon);
labelY.text = "Y: " + numFormater.format(lat);
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="numFormater" precision="2" />
</fx:Declarations>
<esri:Map id="map" mouseMove="mouseMoveHandler(event)"
scaleBarVisible="false" width="100%" height="100%">
<esri:ArcGISDynamicMapServiceLayer
url="http://localhost/ArcGIS/rest/services/Florida/MapServer" />
</esri:Map>
<s:Label id="labelX" text="0" left="20" bottom="15" fontSize="15"/>
<s:Label id="labelY" text="0" left="110" bottom="15" fontSize="15"/>
</s:Application>