关闭

ArcGIS Api For Flex 划选查询功能的实现

标签: ArcGISesriapiflex
1395人阅读 评论(0) 收藏 举报
分类:

如下图所示:

 

 

实现代码如下:

 

<?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
“>
 <fx:Script>
  <![CDATA[
   import com.esri.ags.FeatureSet;
   import com.esri.ags.Graphic;
   import com.esri.ags.components.Navigation;
   import com.esri.ags.events.DrawEvent;
   import com.esri.ags.geometry.MapPoint;
   
   import mx.controls.Alert;
   import mx.controls.Image;
   import mx.events.ItemClickEvent;
   import mx.rpc.AsyncResponder;

 

   
   private var hashmapOfExistingGraphics:Object = new Object();

 

   protected functiontbb_itemClickHandler(event:ItemClickEvent):void
   {
    
    
    switch (event.item.label)
    {
     
     case "POLYGON": {myDrawTool.activate(DrawTool.POLYGON); break; }
     case "ELLIPSE": {myDrawTool.activate(DrawTool.ELLIPSE);
      break; }
           
    }
   }
   
   
   
   protected functionmyDrawTool_drawEndHandler(event:DrawEvent):void
   {
    //
释放

    
    query.geometry=event.graphic.geometry;
    //graphicslayer.clear();
    query.outSpatialReference = Map1.spatialReference;
    queryTask.execute(query, new AsyncResponder(onResult,onFault));

 

    myDrawTool.deactivate();
    tbb.selectedIndex = -1;
    
   
    
   }
   
   private function onResult(featureSet:FeatureSet, token:Object= null):void
   {
    for each (var myGraphic:Graphic in featureSet.features)
    {
     // only add features that are not already in thegraphics layer
     var graphicID:String = myGraphic.attributes.NAME;
     
     if (!hashmapOfExistingGraphics[graphicID]) // Newfeature (not already added to graphics layer)
     {
      hashmapOfExistingGraphics[graphicID] = 1;
      myGraphic.id = graphicID;
      myGraphic.toolTip =myGraphic.attributes.NAME;
   
      myGraphic.symbol=sps;
      graphicslayer.add(myGraphic);
   
     }
    }
   }
    
   

 

   
   private function onFault(info:Object, token:Object =null):void
   {
    Alert.show(info.toString());
   }

 

   
  ]]>
  
 </fx:Script>
 <fx:Declarations>
  <!–
将非可视元素(例如服务、值对象)放在此处
–>
  <esri:PictureMarkerSymbol id=”sps” source=”
http://localhost/Red_glow.swf
“  width=”20″ height=”20″ />
  <esri:SimpleMarkerSymbol id=”sms”
         color=”0x00FF00″
         size=”12″
         style=”square”/>
  
  <!– Symbol for all line shapes –>
  <esri:SimpleLineSymbol id=”sls”
          width=”3″
          color=”0x00FF00″/>
  
  <!– Symbol for all polygon shapes –>
  <esri:SimpleFillSymbol id=”sfs”
          color=”0xFFFFFF”
         style=”diagonalcross”>
   <esri:outline>
    <esri:SimpleLineSymbol width=”2″color=”0x00FF00″/>
   </esri:outline>
  </esri:SimpleFillSymbol>
  <esri:QueryTask id=”queryTask”
      showBusyCursor=”true”
      url=”
http://218.60.144.97:8080/RemoteRest/services/LN_SL/MapServer/9

      useAMF=”false”/>
  
  <esri:Query id=”query”
     outFields=”[NAME,ID]“
     returnGeometry=”true”/>

 

  
  <esri:DrawTool id=”myDrawTool” map=”{Map1}” drawEnd=”myDrawTool_drawEndHandler(event)” fillSymbol=”{sfs}”
        graphicsLayer=”{graphicslayer}”
        lineSymbol=”{sls}”
        markerSymbol=”{sms}”/>
 </fx:Declarations>
 <esri:Map id=”Map1″ >
  <!–<esri:ArcGISTiledMapServiceLayer
  url=”
http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer”/
>–>
  <esri:ArcGISDynamicMapServiceLayer url=”
http://218.60.144.97:8080/RemoteRest/services/LN_SL/MapServer”/
>
  <esri:GraphicsLayer id=”graphicslayer”>
   
  </esri:GraphicsLayer>
 </esri:Map>
 <mx:ToggleButtonBar id=”tbb” itemClick=”tbb_itemClickHandler(event)”toggleOnClick=”true”>
  <fx:Object  label=”POLYGON”/>
  <fx:Object  label=”ELLIPSE”/>
  
 </mx:ToggleButtonBar>
</s:Application>

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:403115次
    • 积分:6851
    • 等级:
    • 排名:第3507名
    • 原创:292篇
    • 转载:3篇
    • 译文:1篇
    • 评论:36条
    最新评论