flex+gis显示地图的比例尺,坐标,地图显示范围

 

Then use the toMapFromStage method to easily get those stage coordinates into map coordinates.
-->
    <mx:Script>
        <![CDATA[
            import com.esri.ags.geometry.MapPoint;

            private function loadHandler():void
            {
                myMap.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
            }

            private function mouseMoveHandler(event:MouseEvent):void
            {
                const mapPoint:MapPoint = myMap.toMapFromStage(event.stageX, event.stageY);//获取当前鼠标的坐标转换成点。
                mousecoords.text = "Latitude: " + mapPoint.y.toFixed(6) //点的Y值坐标(保留六位小数)
                    + "    Longitude: " + mapPoint.x.toFixed(6);
            }
        ]]>
    </mx:Script>

    <mx:HBox width="100%">
        <mx:Label text="Current map extent:" fontWeight="bold"/>
        <mx:Label text="xmin: {myMap.extent.xmin.toFixed(3)}"/>//地图显示范围的最小X值并保留三位小数
        <mx:Label text="ymin: {myMap.extent.ymin.toFixed(3)}"/>
        <mx:Label text="xmax: {myMap.extent.xmax.toFixed(3)}"/>
        <mx:Label text="ymax: {myMap.extent.ymax.toFixed(3)}"/>
    </mx:HBox>
    <mx:HBox width="100%">
        <mx:Label text="Current Mouse Coordinates:" fontWeight="bold"/>
        <mx:Label id="mousecoords" text="Move the mouse over the map to see its current coordinates..."/>
    </mx:HBox>
    <mx:HBox width="100%">
        <mx:Label text="Current map scale:" fontWeight="bold"/>
        <mx:Label text="1:{myMap.scale.toFixed(0)}"/>//地图比例尺(无小数位)
    </mx:HBox>
    <esri:Map id="myMap" load="loadHandler()">
        <esri:extent>
            <esri:Extent xmin="-11" ymin="30" xmax="40" ymax="72">
                <esri:SpatialReference wkid="4326"/>
            </esri:Extent>
        </esri:extent>
        <esri:ArcGISTiledMapServiceLayer
            url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
    </esri:Map>
</mx:Application>

 

http://1984yifeng.blog.163.com/blog/static/4728439120100273342756/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值