<?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:esri="http://www.esri.com/2008/ags" pageTitle="Basic usage of DrawTool"> <s:layout> <s:VerticalLayout paddingBottom="5"/> </s:layout> <fx:Style> @namespace mx "library://ns.adobe.com/flex/mx"; mx|ToolTip { font-size: 14; } </fx:Style> <fx:Script> <![CDATA[ import spark.events.IndexChangeEvent; protected function bb_changeHandler(event:IndexChangeEvent):void { if (event.newIndex == -1) { drawTool.deactivate(); } else { switch (bb.dataProvider.getItemAt(event.newIndex)) { case "Point": drawTool.activate(DrawTool.MAPPOINT); break; case "Multipoint": drawTool.activate(DrawTool.MULTIPOINT); break; case "Single Line": drawTool.activate(DrawTool.LINE); break; case "Polyline": drawTool.activate(DrawTool.POLYLINE); break; case "FreeHand Polyline": drawTool.activate(DrawTool.FREEHAND_POLYLINE); break; case "Polygon": drawTool.activate(DrawTool.POLYGON); break; case "Freehand Polygon": drawTool.activate(DrawTool.FREEHAND_POLYGON); break; case "Rectangle": drawTool.activate(DrawTool.EXTENT); break; } } } ]]> </fx:Script> <fx:Declarations> <!-- Symbol for all point shapes --> <esri:SimpleMarkerSymbol id="sms" color="0x00FF00" size="12" style="square"/> <!-- Symbol for all line shapes --> <esri:SimpleLineSymbol id="sls" color="0x00FF00" width="3"/> <!-- Symbol for all polygon shapes --> <esri:SimpleFillSymbol id="sfs" color="0xFFFFFF" style="diagonalcross"> <esri:outline> <esri:SimpleLineSymbol color="0x00FF00" width="2"/> </esri:outline> </esri:SimpleFillSymbol> <esri:DrawTool id="drawTool" fillSymbol="{sfs}" graphicsLayer="{myGraphicsLayer}" lineSymbol="{sls}" map="{myMap}" markerSymbol="{sms}"/> </fx:Declarations> <s:controlBarLayout> <s:HorizontalLayout horizontalAlign="center" paddingBottom="7" paddingTop="7"/> </s:controlBarLayout> <s:controlBarContent> <s:ButtonBar id="bb" change="bb_changeHandler(event)"> <s:ArrayList> <fx:String>Point</fx:String> <fx:String>Multipoint</fx:String> <fx:String>Single Line</fx:String> <fx:String>Polyline</fx:String> <fx:String>FreeHand Polyline</fx:String> <fx:String>Polygon</fx:String> <fx:String>Freehand Polygon</fx:String> <fx:String>Rectangle</fx:String> </s:ArrayList> </s:ButtonBar> </s:controlBarContent> <esri:Map id="myMap" level="3" useHandCursor="true"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer"/> </esri:Map> <s:Label text="The DrawTool can be used to draw new features which can then either be used as input for another task or saved as new features in a feature service (using the FeatureLayer.applyEdits)" width="100%"/> </s:Application>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.