Newbie Q: Got coordinates of polygon in map units; convert to lat/lon?

283
4
Jump to solution
12-13-2013 07:29 AM
DanielMauer
New Contributor II
This seems like it's probably a slap-your-head easy problem, but an hour of googling forum-browsing and I'm still stuck, likely because I just don't know the terminology to use.

Anyway: I'm using the DrawTool to draw a polygon, then I need to find the lat/lon coordinates of each point in the polygon.  I grab athe Polygon object from the graphics layer's graphicProvider property, then I've got an array of MapPoints for each Ring in the polygon, but the MapPoints are clearly not in lat/lon.  Based on what I've read it sounds like they're in UTM format?

I am (I believe) using the web mercator (wkid: 102100), which other forum posts seem to say should mean this is a straightforward conversion.

So... how do I do it?

Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AndrewTimmins
Regular Contributor
Daniel,

Check out the WebMercatorUtil class. It should help you.
There is a sample linked on the page also..

https://developers.arcgis.com/en/flex/api-reference/index.html?com/esri/ags/utils/WebMercatorUtil.ht...

If that does not work you are going to have to 'project' the geometry using a Geometry Service...

Drew

View solution in original post

0 Kudos
4 Replies
AndrewTimmins
Regular Contributor
Daniel,

Check out the WebMercatorUtil class. It should help you.
There is a sample linked on the page also..

https://developers.arcgis.com/en/flex/api-reference/index.html?com/esri/ags/utils/WebMercatorUtil.ht...

If that does not work you are going to have to 'project' the geometry using a Geometry Service...

Drew

View solution in original post

0 Kudos
DanielMauer
New Contributor II
Yes, fantastic!  That did it.  For anyone else reading this, the specific code I'm now using to take a Graphic (which is of type Polygon) is:

var polygonInGeoCoords:Polygon = WebMercatorUtil.webMercatorToGeographic(myGraphic.geometry) as Polygon;


Thank you!

Daniel,

Check out the WebMercatorUtil class. It should help you.
There is a sample linked on the page also..

https://developers.arcgis.com/en/flex/api-reference/index.html?com/esri/ags/utils/WebMercatorUtil.ht...

If that does not work you are going to have to 'project' the geometry using a Geometry Service...

Drew



					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
AndrewTimmins
Regular Contributor
Glad to hear it worked out.
If you don't mind, please mark the thread as answered. That way it will help others know there is a solution to the question.

Drew
0 Kudos
DanielMauer
New Contributor II
Done.  I'm used to doing that on StackOverflow, but hadn't seen the "checkmark" on any other forums... good to know.

Glad to hear it worked out.
If you don't mind, please mark the thread as answered. That way it will help others know there is a solution to the question.

Drew
0 Kudos