<?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"> <s:layout> <s:VerticalLayout paddingBottom="6"/> </s:layout> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.SpatialReference; import com.esri.ags.events.GeometryServiceEvent; import com.esri.ags.events.MapMouseEvent; import com.esri.ags.geometry.Geometry; import com.esri.ags.geometry.MapPoint; import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.utils.StringUtil; private var grGeometry:MapPoint = new MapPoint(); /** * Listen map mouse down handler */ protected function myMap_mapMouseDownHandler(event:MapMouseEvent):void { grGeometry = event.mapPoint; var geometriesToProject:Array = new Array(); geometriesToProject.push(grGeometry); var wkid:Number = NaN; /* var wkid:Number = 1314; */ var wkt:String = "GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],TOWGS84[375,-111,431,0,0,0,0],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]"; var projectionSR:SpatialReference = new SpatialReference(wkid, wkt); sampleGeometryService.project(geometriesToProject, projectionSR); var gr:Graphic = new Graphic(grGeometry); var grId:String = myGraphicsLayer.add(gr); trace(StringUtil.substitute("Graphic with id: {0} added.", grId)); } /** * Listen geometry service project complete handler */ protected function onProjectComplete(event:GeometryServiceEvent):void { var pt:MapPoint = (event.result as Array)[0] as MapPoint; trace(event.result.toString()); Alert.show(StringUtil.substitute("From: x={0} \ny={1} \nSR={2}; \n\nTo: x={3} \ny={4} \nSR={5}", grGeometry.x, grGeometry.y, grGeometry.spatialReference.toString(), pt.x, pt.y, pt.spatialReference.toString()), "Projection result"); } /** * Listen geometry service fault handeler */ protected function onGeometryServiceFault(event:FaultEvent):void { trace(StringUtil.substitute("onGeometryServiceFault >> {0}", event.message)); Alert.show(event.fault.message, "Projection failt"); } ]]> </fx:Script> <fx:Declarations> <!-- Symbol for all point shapes --> <esri:SimpleMarkerSymbol id="sms" color="0x00FF00" size="12" style="{SimpleMarkerSymbol.STYLE_DIAMOND}"/> <esri:GeometryService id="sampleGeometryService" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" projectComplete="onProjectComplete(event)" fault="onGeometryServiceFault(event)"/> </fx:Declarations> <esri:Map id="myMap" mapMouseDown="myMap_mapMouseDownHandler(event)" level="3" wrapAround180="true"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sms}"/> </esri:Map> </s:Application>
Using ArcGIS server REST Api to project geometries u can input only Well-known ID's (wkid) - as Input/Output Spatial Refences presented here. Using other Api's (Flex Api for expmple) you can create any own or exists Spatial Reference based on Well-Know Text (wkt) if ESRI Well-known ID (wkid) not exists. Tell me where I am wrong.
{"wkt":"PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB36\",DATUM[\"OSGB36\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],TOWGS84[446.448,-125.157,542.06,0.1502,0.247,0.8421,-20.4894],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0.0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.017453292519943295],AXIS[\"Geodetic latitude\",NORTH],AXIS[\"Geodetic longitude\",EAST],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\",AUTHORITY[\"EPSG\",\"9807\"]],PARAMETER[\"central_meridian\",-2.0],PARAMETER[\"latitude_of_origin\",49.0],PARAMETER[\"scale_factor\",0.9996012717],PARAMETER[\"false_easting\",400000.0],PARAMETER[\"false_northing\",-100000.0],UNIT[\"m\",1.0],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"27700\"]]"}
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.