ArcGIS For Flex学习之Mapping---Map Extent and Mouse Coordinates
2014-10-21 14:24
435 查看
效果图如下:
View Code
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Map Extent and Mouse Coordinates"> <fx:Script> <![CDATA[ import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.utils.WebMercatorUtil; // when mouse (cursor) is on the map ... private function loadHandler():void { myMap.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); } // ... show coordinates of current (mouse) location private function mouseMoveHandler(event:MouseEvent):void { const mapPoint:MapPoint = myMap.toMapFromStage(event.stageX, event.stageY); const latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint) as MapPoint; mousecoords.text = "x,y is " + mapPoint.x.toFixed(0) + "," + mapPoint.y.toFixed(0) + " and Lat/Long is: " + latlong.y.toFixed(6) + " / " + latlong.x.toFixed(6); } // convert current projected extent to geographic and show as such protected function showExtentInGeographic(extent:Extent):String { const geoExtent:Extent = WebMercatorUtil.webMercatorToGeographic(myMap.extent) as Extent; // return geoExtent.toString() + ".." ; return " " + geoExtent.xmin.toFixed(6) + ", " + geoExtent.ymin.toFixed(6) + ", " + geoExtent.xmax.toFixed(6) + ", " + geoExtent.ymax.toFixed(6) + " (wkid: " + geoExtent.spatialReference.wkid + ")"; } ]]> </fx:Script> <s:controlBarLayout> <s:VerticalLayout gap="10" paddingBottom="7" paddingLeft="10" paddingRight="10" paddingTop="7"/> </s:controlBarLayout> <s:controlBarContent> <s:RichText width="100%"> This sample demonstrates how to use event listeners on the mouse to display current information about the mouse location. The map's current extent and scale is also displayed as you change the extent by navigating the map (pan/zoom) or use the navigation slider to zoom in/out. </s:RichText> <s:HGroup> <s:Label fontWeight="bold" text="Current map extent:"/> <s:RichEditableText editable="false" text='xmin="{myMap.extent.xmin.toFixed(0)}" ymin="{myMap.extent.ymin.toFixed(0)}" xmax="{myMap.extent.xmax.toFixed(0)}" ymax="{myMap.extent.ymax.toFixed(0)}" (wkid="{myMap.spatialReference.wkid}")'/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current map extent (in geographic):"/> <s:RichEditableText editable="false" text="{showExtentInGeographic(myMap.extent)}"/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current Mouse Coordinates:"/> <s:RichEditableText id="mousecoords" editable="false" text="Move the mouse over the map to see its current coordinates..."/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current map scale is"/> <s:RichEditableText editable="false" text="1:{myMap.scale.toFixed(0)} (level {myMap.level})"/> </s:HGroup> </s:controlBarContent> <esri:Map id="myMap" load="loadHandler()"> <esri:extent> <esri:Extent xmin="3035000" ymin="4305000" xmax="3475000" ymax="10125000"> <esri:SpatialReference wkid="102100"/> <!-- same as tiled map service below --> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> </esri:Map> </s:Application>
View Code
相关文章推荐
- Arcgis silverlight-7 map extent and mouse coordinate
- ArcGIS For Flex学习之Mapping---Select and zoom
- ArcGIS For Flex学习之Mapping---Add LODs for extra zooming
- Some Useful resources for ArcGIS and Flex
- ArcGIS Server API For Flex 学习收集1
- ArcGIS坐标系转换出错:Error 999999执行函数出错 invalid extent for output coordinate system
- ArcGIS Runtime SDK for iOS 开发之地图范围(map extent)
- arcgis api for flex 高级主题(一) esri tilemap 四叉树索引研究<转>
- [ArcGIS for android学习]com.esri.android.map下面有些什么
- arcgis for flex 学习笔记(一)
- ArcGIS RunTime SDK For ios 10.1.1学习笔记(一)HelloMapWorld
- [Esri官方声明]ArcGIS APIs / Viewers for Flex and Silverlight的产品周期
- ArcGIS API For Flex对ImageServer发布的服务进行渲染及RasterFunction支持函数(学习笔记)
- arcgis api for flex 学习笔记
- ArcGIS for Flex中map控件属性
- arcgis api for flex 开发入门(二)map 的创建
- ArcGIS API for Flex and ArcGIS Viewer for Flex 2.2 发布
- arcgis api for flex 高级主题(一) esri tilemap 四叉树索引研究
- arcgis api for flex 开发入门(二)map 的创建<转>
- ArcGis api for flex 中 Map控件的属性开关(地图控件的导航功能开关属性)