效果图如下:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
 3                xmlns:s="library://ns.adobe.com/flex/spark"
 4                xmlns:esri="http://www.esri.com/2008/ags"
 5                pageTitle="Map Extent and Mouse Coordinates">
 6
 7     <fx:Script>
 8         <![CDATA[
 9             import com.esri.ags.geometry.Extent;
10             import com.esri.ags.geometry.MapPoint;
11             import com.esri.ags.utils.WebMercatorUtil;
12
13             // when mouse (cursor) is on the map ...
14             private function loadHandler():void
15             {
16                 myMap.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
17             }
18
19             // ... show coordinates of current (mouse) location
20             private function mouseMoveHandler(event:MouseEvent):void
21             {
22                 const mapPoint:MapPoint = myMap.toMapFromStage(event.stageX, event.stageY);
23                 const latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint) as MapPoint;
24                 mousecoords.text =
25                     "x,y is " + mapPoint.x.toFixed(0) + "," + mapPoint.y.toFixed(0)
26                     + " and Lat/Long is: " + latlong.y.toFixed(6)
27                     + " / " + latlong.x.toFixed(6);
28             }
29
30             // convert current projected extent to geographic and show as such
31             protected function showExtentInGeographic(extent:Extent):String
32             {
33                 const geoExtent:Extent = WebMercatorUtil.webMercatorToGeographic(myMap.extent) as Extent;
34                 // return geoExtent.toString() + ".." ;
35                 return " " + geoExtent.xmin.toFixed(6)
36                     + ", " + geoExtent.ymin.toFixed(6)
37                     + ", " + geoExtent.xmax.toFixed(6)
38                     + ", " + geoExtent.ymax.toFixed(6)
39                     + "   (wkid: " + geoExtent.spatialReference.wkid + ")";
40             }
41         ]]>
42     </fx:Script>
43
44     <s:controlBarLayout>
45         <s:VerticalLayout gap="10"
46                           paddingBottom="7"
47                           paddingLeft="10"
48                           paddingRight="10"
49                           paddingTop="7"/>
50     </s:controlBarLayout>
51     <s:controlBarContent>
52         <s:RichText width="100%">
53             This sample demonstrates how to use event listeners on the
54             mouse to display current information about the mouse location.
55             The map's current extent and scale is also displayed as you
56             change the extent by navigating the map (pan/zoom) or use the
57             navigation slider to zoom in/out.
58         </s:RichText>
59         <s:HGroup>
60             <s:Label fontWeight="bold" text="Current map extent:"/>
61             <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}")'/>
62         </s:HGroup>
63         <s:HGroup>
64             <s:Label fontWeight="bold" text="Current map extent (in geographic):"/>
65             <s:RichEditableText editable="false" text="{showExtentInGeographic(myMap.extent)}"/>
66         </s:HGroup>
67         <s:HGroup>
68             <s:Label fontWeight="bold" text="Current Mouse Coordinates:"/>
69             <s:RichEditableText id="mousecoords"
70                                 editable="false"
71                                 text="Move the mouse over the map to see its current coordinates..."/>
72         </s:HGroup>
73         <s:HGroup>
74             <s:Label fontWeight="bold" text="Current map scale is"/>
75             <s:RichEditableText editable="false" text="1:{myMap.scale.toFixed(0)} (level {myMap.level})"/>
76         </s:HGroup>
77     </s:controlBarContent>
78
79     <esri:Map id="myMap" load="loadHandler()">
80         <esri:extent>
81             <esri:Extent xmin="3035000" ymin="4305000" xmax="3475000" ymax="10125000">
82                 <esri:SpatialReference wkid="102100"/>
83                 <!-- same as tiled map service below -->
84             </esri:Extent>
85         </esri:extent>
86         <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
87     </esri:Map>
88
89 </s:Application>

View Code

转载于:https://www.cnblogs.com/wicked-fly/p/4040284.html

ArcGIS For Flex学习之Mapping---Map Extent and Mouse Coordinates相关推荐

  1. ArcGIS Runtime SDK for iOS 开发之地图范围(map extent)

    注:本篇文章翻译自:https://developers.arcgis.com/ios/objective-c/guide/iphonesdk-mapnavigation.htm: 地图视图包含了地图 ...

  2. 【专注学习】基于Arcgis的python学习1

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 [专注学习]基于Arcgis的python学习1 前言 一.主体思路流程? 二.需要用到的函数 1.清除所有变量 2.读入数据-loa ...

  3. ArcGIS Server9.2学习开发(4)——使用Toc控件

    在<ArcGIS Server9.2学习开发(3)--使用Map控件>中讲解了有关ArcGIS Server9.2为我们提供的Map控件的基本用法,然而仅仅只有Map控件是远远不够的,还需 ...

  4. 案例学习——Interior Mapping 室内映射(假室内效果)

    最近油管推荐了Interior Mapping的教程,发现很有意思,但各种资料似乎比较零散 于是到处搜集了一些,有了这篇文章汇总,一起学习 案例学习--Interior Mapping 室内映射(假室 ...

  5. ArcGis For Flex 之 QueryTask地理坐标展现【原创】

    本功能仿照Google Map分类搜索做的,可以看Google效果:http://ditu.google.cn/maps?hl=zh-CN&tab=wl 现在说说从查询到画出标注的具体经过,贴 ...

  6. Flex学习笔记(零)

    推荐Flex的初学者学习Adobe官方提供的Flex in a Weekvideo series, Flex 4.5.这一系列教程虽然是英文视频,但是Adobe很贴心地给出了pdf格式的视频内容和源代 ...

  7. Flash/Flex学习笔记(30):不用startDrag和stopDrag的对象拖动

    对于从Sprite类继承来的对象,要实现拖放当然是Flash/Flex学习笔记(13):对象拖动(startDrag/stopDrag) 里讲的方法最方便,但是对于不是从Sprite类继承得来的对象, ...

  8. Flex学习笔记(1)——入门,HelloFlex

    稍微有些资历的Web程序员想必都还记得Macromedia这个公司吧,想当初网页编程三剑客:Dreamweaver.Flash.Fireworks是多么的红火,可惜现在Macromedia已经是一个过 ...

  9. flex学习网站大全(转)

    FLEX学习网站大全(转) 2007-06-09 16:49 FLEX学习网站大全 [ 2007-5-9 13:19:00 | By: maybe ] 转自[http://www.zhuoqun.ne ...

最新文章

  1. LeetCode 763. 划分字母区间
  2. 1.10 throws和throw:声明和抛出异常
  3. RPC 和 RESTful对比
  4. android 动态改变语言,android动态设置app当前运行语言的方法
  5. Microsoft SQL Server Management Studio(SSMS)概述
  6. linux HZ 值_Linux操作系统中进程的操作命令(ps,kill,keep)
  7. 小程序input textarea 禁止粘贴实现
  8. 【信息学奥赛一本通 提高组】第三章 深搜的剪枝技巧
  9. 爬虫练习生|爬虫前奏(爬虫介绍、工具的安装、爬虫分类、爬虫须知)
  10. 热烈欢迎Ubuntu志愿者!
  11. 关于python中面向对象(一)
  12. 市面上常用的语音识别模块主要包含哪些组件?
  13. python以图搜图_以图搜图(一):Python实现dHash算法(转)
  14. poj1601 青蛙的约会 (扩展欧几里得)
  15. 操作系统--时间片轮转调度算法(RR算法)
  16. matlab时域计算频率,基于MATLAB 的信号时域采样及频率混叠现象分析
  17. 好玩的熊猫头表情包图片生成PHP源码+实测可用
  18. 节拍器(HTML5版)
  19. 统一加速器发布 pro V0.9805 版本
  20. MATLAB怎么安装fieldtrip,FieldTrip

热门文章

  1. Firefox 67不能勾选“以后自动采用相同的动作处理此类文件”解决方案
  2. 5G汽车联盟与欧洲汽车电信联盟签署合作谅解备忘录
  3. java 多线程 一个博客
  4. Java从入门到精通07-排序
  5. mysql-定时调用存储过程
  6. c语言中的函数可变参数列表相关的三个宏
  7. ChaLearn Gesture Challenge_3:Approximated gradients源码简单分析
  8. 给Eclipse安装MinGW
  9. 我用Python爬虫挣钱的那点事
  10. width:100%与绝对定位同时存在,偏移出父级容器