基于Flex的MapGIS web开发——地图操作

//首先显示地图是一个基本,在窗体是上使用IMSMap控件,TileLayer控件,VectorMapDoc控件,,不多说了上代码


<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="955" minHeight="600"    xmlns:map="zdims.map.*">

    

    <fx:Declarations>
        <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    </fx:Declarations>
    <map:IMSMap x="142" y="23" width="703" height="566" xMaxMap="114.5007" xMinMap="114.1256" yMaxMap="30.83" yMinMap="30.44" levelNum="7" id="mymap">
        <map:TileLayer x="196" y="296" hdfName="whmap.hdf" serverAddress="http://localhost:5142" id="title">
        </map:TileLayer>
        <map:IMSEagleEye x="478" y="402" width="200" height="200" eagleLocation="右下" id="eagle">
        
        <map:VectorMapDoc x="598" y="376" mapDocName="wh.map" serverAddress="http://localhost:5141">
        
        </map:VectorMapDoc>
        </map:IMSEagleEye>
        <s:Button x="0" y="0" label="显示/隐藏鹰眼按钮" name="btn" click="button1_clickHandler(event)"/>
        <s:Button x="116" y="1" label="ShowHDF" click="button2_clickHandler(event)"/>
        <s:Button x="192" y="1" label="ShowMap" click="button3_clickHandler(event)"/>
        <s:Button x="266" y="1" label="width" id="widths" click="getWidth()"/>
        <s:Button x="336" y="1" label="height" id="heights" click="getHeight()"/>
        <s:Button x="405" y="1" label="复位" click="restore(event)"/>
        <s:Button x="474" y="1" label="刷新"/>
        <s:Button x="542" y="1" label="显示3级瓦片" click="ShowLevel"/>
        <s:Button x="629" y="0" label="居中显示"/>
        <s:Button x="10" y="33" label="移动到(114.2,30.5)"/>
        <s:Button x="148" y="33" label="切换显示状态"/>
    </map:IMSMap>
    
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            
            import zdims.map.TileLayer;
            import zdims.map.VectorMapDoc;
            private var doc:VectorMapDoc=null;
            private var tilmap:TileLayer=null;
            
            protected function button1_clickHandler(event:MouseEvent):void
            {
                this.eagle.switchEagleEye();
            }
            
            protected function button2_clickHandler(event:MouseEvent):void
            {
                if(doc!=null)
                {
                    this.mymap.removeElement(doc)
                }
                if(tilmap==null)
                {
                    tilmap=new TileLayer();
                    tilmap.serverAddress="http://localhost:5142";
                    tilmap.hdfName="whMap.hdf";
                }
                this.mymap.addElement(tilmap);
            }    
            protected function button3_clickHandler(event:MouseEvent):void
            {
                if(tilmap!=null)
                {
                    this.mymap.removeElement(tilmap)
                }
                if(doc==null)
                {
                    doc=new VectorMapDoc();
                    doc.serverAddress="http://localhost:5141";
                    doc.mapDocName="wh.map";                    
                }
                this.mymap.addElement(doc);
            }
                
            public function getWidth():void
            {
            Alert.show("Width="+mymap.width);
            }
            public function getHeight():void 
            {
                Alert.show("Height="+mymap.height);
            }

            import zdims.util.IMSOperType;

            protected function restore(event:MouseEvent):void
            {
                //this.mymap.setCurOper(IMSOperType.Restore);
                this.mymap.restore(true); //这种方式也能够实现复位
            }
            import zdims.util.IMSOperType;
            public function refresh():void
            {
                this.mymap.setCurOper(IMSOperType.Refresh);
                //this.mymap.refresh();
            }
            public function ShowLevel():void
            {
                this.mymap.setLevel(3);
            }
            public function ceterClick():void
            {
                this.mymap.setCenter(114.2,30.5);
            }
            public function MoveT():void
            {
                this.mymap.panTo(114.2,30.5);
            }
            public function displayState():void
            {
        this.title.display=!this.title.display;
            }

        ]]>
    </fx:Script>
    
<!--    <fx:Script>
        <![CDATA[
            import zdims.map.IMSMap;
            import zdims.map.TileLayer;
            import zdims.map.VectorMapDoc;
            public function addIMSMap():void
            {
                var map:IMSMap=new IMSMap();
                map.height=800;
                map.width=600;
                map.x=200;
                map.y=20;
                map.levelNum=7;
                map.xMaxMap=114.500789;
                map.xMinMap=114.125686;
                map.yMaxMap=30.46;
                map.yMinMap=30.83;
                var vectormap:VectorMapDoc=new VectorMapDoc();
                vectormap.mapDocName="wh.map";
                vectormap.serverAddress="http://localhost:5141/";
                map.addElement(vectormap);
                this.addElement(map);
            }
        ]]>
        
        </fx:Script>-->

</s:Application>

 

 总结:地图的控制主要是使用zdims.util.IMSOperType;

然后调用一些IMSOPerTypr.Restorehe  IMSOperType.Refresh,当然这些方法全部是在IMSMap中:IMSMap的id="mymap",则mymap.restore(true)//复位;mymap.refresh(true)//刷新,mymap.setLevel(int x)//显示x级瓦片数据;mymap.setCenter(x,y)//显示到屏幕中间mymap.panTo(x,y)//移动到(x,y)这个位置。

转载于:https://www.cnblogs.com/GIS-bao/archive/2012/12/12/2815460.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值