<?xml version="1.0" encoding="utf-8"?> <mx: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"> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.SpatialReference; import com.esri.ags.geometry.MapPoint; import com.esri.ags.geometry.Polygon; import com.esri.ags.layers.GraphicsLayer; import com.esri.ags.utils.WebMercatorUtil; import mx.events.FlexEvent; protected function myGraphicsLayer_creationCompleteHandler(event:FlexEvent):void { var polygon:Polygon = new Polygon([[ new MapPoint(-85.75041310899991,33.72542224500006 ), new MapPoint(-85.73190945499994,33.657326939000086), new MapPoint(-85.82494958099994,33.68269326400008), new MapPoint(-85.75041310899991,33.72542224500006)]],new SpatialReference(4326)) polygon.addRing([ new MapPoint(-85.75630669999993,33.71122135300004), new MapPoint(-85.80296428299994,33.68655667500008), new MapPoint(-85.74392047999993,33.668993786000044), new MapPoint(-85.75630669999993,33.71122135300004) ]); var mercPoly:Polygon = WebMercatorUtil.geographicToWebMercator(polygon) as Polygon; myMap.extent = mercPoly.extent.expand(2); myGraphicsLayer.add(new Graphic(mercPoly)); } ]]> </fx:Script> <esri:Map id="myMap"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> <esri:GraphicsLayer id="myGraphicsLayer" creationComplete="myGraphicsLayer_creationCompleteHandler(event)"/> </esri:Map> </mx:Application>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.