Flex 加载地图
一、Arcgis for Flex api方法介绍 ???? a.AddLayer(layer:Layer,index:int = -1);向地图添加一个图层。 ???? b.使用ActionScript地图上添加一层 ?????? var myGraphicsLayer:GraphicsLayer = new GraphicsLayer(); ????? ?myMap.addLayer(myGraphicsLayer); 二. MAP属性介绍 ? ? 1.scale 地图比例尺 ? ? ?2.extent?地图范围 ? ? ?3.infoWindow?地图的信息窗口 ? ? ?4.initialExtent?地图的初始程度 ? ? 三、代码 1.ArcGis for Flex Api 简单加载地图 <?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" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <esri:Map id="myMap"> <esri:extent> <esri:Extent xmin="-14298000" ymin="2748000" xmax="-6815000" ymax="7117000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer"/> </esri:Map> </s:Application>
Map_Service.xml <?xml version="1.0" encoding="UTF-8"?> <serives> <serive id="img_map_1" type="agtmp" clas="ArcGISTiledMapServiceLayer" name="电子地图" url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer"> </serive> <scal> <sc data="80000000"></sc> </scal> </serives>
<?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" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init()" > <fx:Script> <![CDATA[ import mx.events.FlexEvent; import mx.events.MoveEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.HTTPService; import com.esri.ags.layers.ArcGISDynamicMapServiceLayer; import com.esri.ags.layers.ArcGISImageServiceLayer; import com.esri.ags.layers.ArcGISTiledMapServiceLayer; import com.esri.ags.layers.Layer; [Bindable] private var _map:Map; [Bindable] public var mapType:String; [Bindable] public var proxyUrl:String; [Bindable] public var scaleValue:Number; public var layer:ArcGISTiledMapServiceLayer=new ArcGISTiledMapServiceLayer(); public var layer2:ArcGISTiledMapServiceLayer=new ArcGISTiledMapServiceLayer(); public var layer3:ArcGISTiledMapServiceLayer=new ArcGISTiledMapServiceLayer(); public var currentBaseMapId:String; public var configxml:XML; protected function init_loadMap(event:FlexEvent):void { var service:HTTPService=new HTTPService(); service.url="xml/Map_Service.xml"; service.resultFormat="e4x"; service.addEventListener(ResultEvent.RESULT,onResultHandler); service.send(); } public function onResultHandler(evt:ResultEvent):void { configxml=XML(evt.result); proxyUrl=configxml.serive.@url; mapType=configxml.serive.@clas; scaleValue=configxml.scal.sc.@data; addLayers(proxyUrl,mapType); } public function addLayers(url:String,maptype:String):void{ switch (maptype) { case "WMSMapServiceLayer": layer.id=currentBaseMapId; this.map.addLayer(Layer(layer),0); break; case "ArcGISTiledMapServiceLayer": layer.url=url; layer.id=currentBaseMapId; this.map.addLayer(Layer(layer),0); break; case "ArcGISDynamicMapServiceLayer": layer3.url=url; layer3.id=currentBaseMapId; this.map.addLayer(Layer(layer3),0); break } } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <esri:Map initialize="init_loadMap(event)" scale="{scaleValue}" id="map" > </esri:Map> </s:Application> 导入swf文件地址放到项libs 文件夹下即可。下载地址:http://download.csdn.net/detail/allen_gang/5681675 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |