如下图所示:
?

?
实现代码如下:
?
<?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>