Latitude and Longtitude

3292
6
Jump to solution
03-27-2013 07:21 PM
Labels (1)
StanleyHo
New Contributor III
Hi,

I need to draw polygons on the map but the polygon  coordinates is based on latitude and longitude.

How do I convert latitude and longitude from map X and Y coordinate?
How do I do the reverse?
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

Yes the WebMercator class is part of the API and therefore will remain alongside your application if it goes "offline". You can also use the LocalGeometryService offline, if you're using the Standard license level.

To use cached maps offline you'll need to create a Tile Package, or take a copy/extract of the server-side cache.

Cheers

Mike

View solution in original post

0 Kudos
6 Replies
DavidMartin
Occasional Contributor II
You can use the GeometryService to project between different coordinate systems. The Project tool will also take a datum transformation if needed. See http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli...
0 Kudos
StanleyHo
New Contributor III
Thanks for the reply.

I am having trouble understanding GeometryService that you mention. i can't seems to find the latitude, longitude conversion and vice versa.

However, from the samples, I discover that it plots the polygon based on latitude and longitude.

Here is the code:

string polyCoordinate = "2.5,-1 2.5,1 -2.5,1 -2.5,-1 2.5,-1";
ESRI.ArcGIS.Client.Geometry.PointCollectionConverter pointConverter = new ESRI.ArcGIS.Client.Geometry.PointCollectionConverter();
ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = pointConverter.ConvertFromString(polyCoordinate) as ESRI.ArcGIS.Client.Geometry.PointCollection;

//setup the polygon
Polygon aoi = new Polygon();
aoi.Rings.Add(pointCollection);

BrushConverter brushConv = new BrushConverter();
SimpleFillSymbol symbol = new SimpleFillSymbol();
symbol.BorderBrush = brushConv.ConvertFromString(areaData.Color) as SolidColorBrush;
symbol.BorderThickness = 1;
symbol.Fill = brushConv.ConvertFromString(areaData.FillColor) as SolidColorBrush;

ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
Graphic polygon = new Graphic();
polygon.Geometry = mercator.FromGeographic(aoi);
polygon.Symbol = symbol;
graphicsLayer.Graphics.Add(polygon);


Each point is based on latitude and longitude value.
However, I got a problem. Firstly, my web will be cached map (downloaded periodically and use offline) and not downloaded realtime.
Is WebMercator still usable?
If WebCator isn't usable, can show me an example on how to convert map point to latitude and longitude and vice versa?

Thanks
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

If you're translating between WGS1984 and Web Mercator Auxiliary Sphere there is a WebMercator class to support this very common case: http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli....

Otherwise - for the greatest flexibility you should look at http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli....

Cheers

Mike
0 Kudos
StanleyHo
New Contributor III
Thanks for the reply.

I got a question if the cached map (in WebMercator format) is downloaded from the web?
When I take the cache map offline, can I still use the webMercator class to transalte between WGS1984 and webmercator and vice versa?
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Yes the WebMercator class is part of the API and therefore will remain alongside your application if it goes "offline". You can also use the LocalGeometryService offline, if you're using the Standard license level.

To use cached maps offline you'll need to create a Tile Package, or take a copy/extract of the server-side cache.

Cheers

Mike
0 Kudos
StanleyHo
New Contributor III
Thanks. I will look into the LocalGeometryService.
0 Kudos