下面的代码实现基本的地图。用esri公司提供的为例 第2个url自己换个喜欢的图
<mx:Canvas id="canvas" width="100%" height="100%" borderStyle="solid" borderThickness="2" borderColor="#439AD7">
<esri:Map id="map" logoVisible="false" panArrowsVisible="true">
<esri:ArcGISDynamicMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer id = "map1" url="http://server.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer"/>
</esri:ArcGISDynamicMapServiceLayer>
</esri:Map>
</mx:Canvas>
下面的代码是 读取xml是的 url连接 和xml里面的第一个title的显示
<mx:HTTPService id="myService" url="*.xml" result="resultHandler(event)" />
<mx:Text id="txt" text="{myData.getItemAt(0).title}" />
下面是script的完整代码 实现点的自定义位置高亮显示和闪烁
private var graphicslayer:GraphicsLayer=new GraphicsLayer();
public function init():void
{
myService.send();
map.addLayer(graphicslayer);
this.map.addEventListener(ZoomEvent.ZOOM_END,mouseZ);
var t:Timer = new Timer( 500,20 );
t.addEventListener( TimerEvent.TIMER, onTimer );
t.start();
}
public function mouseZ(event:ZoomEvent):void
{
if(this.map1.visible == false)
{
this.map1.visible =true;
var mapPoint:MapPoint =new MapPoint();
mapPoint.x =121.123123;
mapPoint.y =31.12341;
this.map.centerAt(mapPoint);
this.map.scale = 1800000;
}
}
public function onTimer(event:Event):void
{
graphicslayer.clear();
var mapPoint:MapPoint =new MapPoint();
mapPoint.x =121.123123;
mapPoint.y =31.12341;
var simpleMarkerS:SimpleMarkerSymbol=new SimpleMarkerSymbol();
simpleMarkerS.color=0x00FF00;
simpleMarkerS.size =10;
// circle园 triangle三角 square方形 diamond菱形 cross十字 X
simpleMarkerS.style ="circle";
var graphics:Graphic=new Graphic();
graphics.symbol =simpleMarkerS;
graphics.geometry =mapPoint;
graphicslayer.add(graphics);
}
[Bindable]
private var myData:ArrayCollection;
private function resultHandler(event:ResultEvent):void {
myData = event.result.books.item;
}
分享到:
评论