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
“>
 <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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值