我在这里记载的东西是平时积累的东西,对新鲜事物的追求一直是做为程序员的我的最大爱好。刚学习arcgis server。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="init()" xmlns:esri="http://www.esri.com/2008/ags">
<mx:Script>
<![CDATA[
import com.esri.ags.events.LayerEvent;
import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;
import com.esri.ags.layers.LayerInfo;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.IndexChangedEvent;
private var urlx:String="http://localhost:8399/arcgis/rest/services/baseMap/MapServer";
public function init():void{
arcLayer.addEventListener(LayerEvent.LOAD,loadMapLayer);
}
private function loadMapLayer(event:LayerEvent):void {
var layerInfos:Array=arcLayer.layerInfos;
var layers:Array = new Array();
var li:LayerInfo;
for(var i:int=0;i<layerInfos.length;i++){
li=layerInfos[i] as LayerInfo;
layers.push({label:li.name,data:li.id});
}
layerList.dataProvider=layers;
}
]]>
</mx:Script>
<mx:Canvas width="400" height="400" x="0" y="20">
<mx:ComboBox id="layerList" x="0" y="10"></mx:ComboBox>
<esri:Map id="myMap" x="0" y="40">
<esri:ArcGISDynamicMapServiceLayer id="arcLayer" url="{urlx}" width="400" height="300"/>
</esri:Map>
</mx:Canvas>
</mx:Application>