<?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" minWidth="955" minHeight="600"
xmlns:esri="http://www.esri.com/2008/ags" xmlns:symbols="com.esri.ags.symbols.*">
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
protected function btn1_changeHandler(event:IndexChangeEvent):void
{
switch (btn1.selectedItem)
{
case "点":
drawtool1.activate(com.esri.ags.tools.DrawTool.MAPPOINT);
break;
case "多点":
drawtool1.activate(com.esri.ags.tools.DrawTool.MULTIPOINT);
break;
case "线":
drawtool1.activate(com.esri.ags.tools.DrawTool.LINE);
break;
case "线段":
drawtool1.activate(com.esri.ags.tools.DrawTool.POLYLINE);
break;
case "多边形":
drawtool1.activate(com.esri.ags.tools.DrawTool.POLYGON);
break;
case "自由多边形":
drawtool1.activate(com.esri.ags.tools.DrawTool.FREEHAND_POLYGON);
break;
case "自由线段":
drawtool1.activate(com.esri.ags.tools.DrawTool.FREEHAND_POLYLINE);
break;
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<esri:PictureMarkerSymbol source="user4.png" id="pic1" />
<esri:SimpleLineSymbol color="0x000000" width="5" id="linesymbol1" />
<esri:SimpleFillSymbol id="fillsymbol1" color="0xFF0000" alpha="0.6" style="cross" outline="{linesymbol1}" />
<esri:DrawTool map="{map1}" markerSymbol="{pic1}" fillSymbol="{fillsymbol1}" lineSymbol="{linesymbol1}" id="drawtool1" graphicsLayer="{myGraphic}"/>
</fx:Declarations>
<esri:Map id="map1">
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
<esri:GraphicsLayer id="myGraphic" />
<esri:GraphicsLayer id="graphic2" />
</esri:Map>
<s:ButtonBar x="88" y="10" id="btn1" change="btn1_changeHandler(event)">
<s:ArrayCollection>
<fx:String>点</fx:String>
<fx:String>多点</fx:String>
<fx:String>线</fx:String>
<fx:String>线段</fx:String>
<fx:String>多边形</fx:String>
<fx:String>自由多边形</fx:String>
<fx:String>自由线段</fx:String>
</s:ArrayCollection>
</s:ButtonBar>
</s:Application>