ArcGIS Api For Flex 动态画点和线

Posted gccbuaa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArcGIS Api For Flex 动态画点和线相关的知识,希望对你有一定的参考价值。

<?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:mx="library://ns.adobe.com/flex/mx" xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags"
      initialize="init()"
      >     
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.geometry.Polyline;
   import com.esri.ags.layers.GraphicsLayer;
   import com.esri.ags.symbols.SimpleLineSymbol;
   import com.esri.ags.symbols.SimpleMarkerSymbol;

   import mx.controls.Alert;
   private var arr:Array=
    [new MapPoint(123.361328,41.265625,new SpatialReference(5326)),
     new MapPoint(123.720703,41.703125,new SpatialReference(5326)),
     new MapPoint(123.431641,41.320313,new SpatialReference(5326)),
     new MapPoint(123.646484,41.515625,new SpatialReference(5326)),
     new MapPoint(123.763272,41.734675,new SpatialReference(5326)),
     new MapPoint(123.248047,41.710938,new SpatialReference(5326)),
     new MapPoint(124.248047,42.510938,new SpatialReference(5326)),
     new MapPoint(123.748047,43.210938,new SpatialReference(5326)),
     new MapPoint(123.748047,43.210938,new SpatialReference(5326))
    ];
   private var polyine:Polyline=new Polyline();
   private var graphicsLayer:GraphicsLayer=new GraphicsLayer();
   private var grahpic:Graphic=new Graphic();
   
   private function init():void
   {
    graphicsLayer.add(grahpic);
    Map.addLayer(graphicsLayer);
   }      
   private function PlayPoint(e:MouseEvent):void
   {
    
    graphicsLayer.clear();
    var i:int=0;
    var timer:Timer = new Timer(1000, arr.length-1);
    timer.addEventListener(TimerEvent.TIMER, TimerMethod);
    timer.start();
    function TimerMethod(event:TimerEvent):void
    {
     var mps:Array=new Array;
     var mpStat:MapPoint=arr[i] as MapPoint;
     
     
     grahpic=new Graphic(mpStat,sps);
     
     graphicsLayer.add(grahpic);
     i=i+1;
    }
   }
   private function PlayLine(e:MouseEvent):void
   {
    
    polyine=new Polyline();
    var i:int=0;
    var timer:Timer = new Timer(1000, arr.length-1);
    timer.addEventListener(TimerEvent.TIMER, TimerMethod);
    timer.start();
    function TimerMethod(event:TimerEvent):void
    {
     var mps:Array=new Array;
     var mpStat:MapPoint=arr[i] as MapPoint;
     var mpEnd:MapPoint=arr[i+1] as MapPoint;
     mps.push(mpStat);
     mps.push(mpEnd);
     polyine.addPath(mps);
        
     grahpic=new Graphic(polyine,sls);
     
     graphicsLayer.add(grahpic);
     i=i+1;
    }
   }
     
   
  ]]>
 </fx:Script>
 <fx:Declarations>
  <!-- 将非可视元素(比如服务、值对象)放在此处 -->
  <esri:SimpleLineSymbol id="sls"
          width="3"
          color="0x00FF00"/>
  <esri:SimpleMarkerSymbol id="sms"
         color="0x00FF00"
         size="12"
         style="square"/>
  <esri:PictureMarkerSymbol id="sps" source="http://localhost/Red_glow.swf"  width="20" height="20" />
 
 </fx:Declarations>
 <esri:Map id="Map" >
  <esri:ArcGISDynamicMapServiceLayer url="xxx "/>

 </esri:Map>
 
  
 <mx:ControlBar  width="100%" top="0" left="0" paddingTop="0" paddingBottom="0"   horizontalAlign="left" >
  <mx:Button label="開始点轨迹"  width="100" fontSize="12" click="PlayPoint(event)"/>
  <mx:Button label="開始线轨迹"  width="100" fontSize="12" click="PlayLine(event)"/>
 </mx:ControlBar>

 
</s:Application>







































































































以上是关于ArcGIS Api For Flex 动态画点和线的主要内容,如果未能解决你的问题,请参考以下文章

基于ArcGIS Flex API实现动态标绘(1.2)

ArcGIS API for JavaScript 4.2学习笔记[30] 点和线高程查询(第八章完结)

arcgis api for flex之专题图制作(饼状图,柱状图等)

天津政府应急系统之GIS一张图(arcgis api for flex)解说显示地图坐标系模块

天津政府应急系统之GIS一张图(arcgis api for flex)解说鹰眼模块

ArcGIS API for Silverlight动态标绘的实现