<?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" creationComplete="init()"> <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 com.esri.ags.events.DrawEvent; import com.esri.ags.events.GeometryServiceEvent; import com.esri.ags.geometry.Geometry; import com.esri.ags.geometry.MapPoint; import com.esri.ags.geometry.Polygon; import com.esri.ags.geometry.Polyline; import com.esri.ags.tasks.supportClasses.LengthsParameters; import com.esri.ags.tasks.supportClasses.LinearUnit; import mx.controls.Alert; import spark.events.IndexChangeEvent; protected function GeoServe_lengthsCompleteHandler(event:GeometryServiceEvent):void { var distArr:Array = event.result as Array; var dist:Number var distTxt:String = ""; for each(dist in distArr){ distTxt += "Side Length: " + dist.toString() + "\n"; } Alert.show(distTxt); } protected function init():void { drawTool.activate(DrawTool.POLYGON); } protected function drawTool_drawEndHandler(event:DrawEvent):void { var geom:Geometry = event.graphic.geometry; var plArr:Array = []; var poly:Polygon = geom as Polygon; var mpArr:Array = poly.rings[0]; var mp:MapPoint; var pl:Polyline; for (var i:int = 1; i < mpArr.length; i++) { var pla:Array = []; pla.push(mpArr[i - 1]); pla.push(mpArr); pl = new Polyline([pla],myMap.spatialReference); plArr.push(pl); } var lengthsParameters:LengthsParameters= new LengthsParameters(); lengthsParameters.geodesic = true; lengthsParameters.polylines = plArr; GeoServe.lengths(lengthsParameters); } ]]> </fx:Script> <fx:Declarations> <!-- 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}" drawEnd="drawTool_drawEndHandler(event)"/> <esri:GeometryService id="GeoServe" lengthsComplete="GeoServe_lengthsCompleteHandler(event)" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/> </fx:Declarations> <esri:Map id="myMap" level="3"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer"/> </esri:Map> </s:Application>
i am looking for similar help. I need to display length of each vertex's in the polygon. help would be much appreciated.
you may use the code provided in the forum .
I forgot what did I do for resolving.
I hope I had used the same code.
where do i input that code?
If you are using adobe Flex code for development , you may use this code to
execute it
also, I don't need to draw in any polygons I just need it to display the length of each polyline in each polygon.
i tried the code it did not work