zoukankan      html  css  js  c++  java
  • ArcGIS For Flex学习之Mapping---Map Extent and Mouse Coordinates

    效果图如下:

     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
  • 相关阅读:
    Redis接口限流
    CentOS7以下DNS失效问题
    Vue的安装与使用
    使用 REDIS保存SESSION信息
    ThinkPHP 阿里云图片上传
    Laravel6.0+easywechat4.1获取用户授权例子与分享示例
    1.oracle创建本地数据库步骤及导入数据
    16、React Native实战之TextInput组件
    14.React Native实战之Navigator组件初探
    13.React Native实战之Text组件
  • 原文地址:https://www.cnblogs.com/wicked-fly/p/4040284.html
Copyright © 2011-2022 走看看