Change Coordinates for Offline Map

1602
2
Jump to solution
12-21-2012 06:47 AM
GSauers
Occasional Contributor
Hello, I am using cached maps on a Nexus 7 that I created using the ArcGIS Desktop application ArcMap 10.1. I get the maps to display no problem, but to place a point on the map I have to use the geolocation in meters. For example:

Point p = new Point(-8344494.546, 4806153.75);
Graphic g = new Graphic(p, new SimpleMarkerSymbol(Color.RED, 25, STYLE.CIRCLE));

This displays a red dot at the location I want, but I want to use Latitude and Longitude versus the meter units used above to make Point p.

Is there a way to create a map that uses Decimal Degrees so I can create a point using Latitude and Longitude? Do I need to do unit conversions?

Thank you in advance for any help.
0 Kudos
1 Solution

Accepted Solutions
GSauers
Occasional Contributor
Thank you for the response. I used the following lines of code to convert the coordinates, which were placed in the OnStatusChanged method within onCreate(). Hope this helps others in the future.

double y = 30.27546;
double x = -55.05836;
Point p = new Point(x, y);

Point mapPoint = (Point) GeometryEngine.project(p, SpatialReference.create(4326), map.getSpatialReference());

Graphic graphic = new Graphic(p,new SimpleMarkerSymbol(Color.RED,25,STYLE.CIRCLE));
gLayer.addGraphic(graphic);
map.addLayer(gLayer);

View solution in original post

0 Kudos
2 Replies
wangzhifang
Occasional Contributor
You can just using Project methond on GeometryEngine class. This is the correct way to do spatail reference convertion. For instance, if your spatial reference of map is WGS1984 WebMercator(wkid3857) and you want to convert the coords to latitude and longitude, just set the in sr=3857 and out sr=4326(WGS1984).
0 Kudos
GSauers
Occasional Contributor
Thank you for the response. I used the following lines of code to convert the coordinates, which were placed in the OnStatusChanged method within onCreate(). Hope this helps others in the future.

double y = 30.27546;
double x = -55.05836;
Point p = new Point(x, y);

Point mapPoint = (Point) GeometryEngine.project(p, SpatialReference.create(4326), map.getSpatialReference());

Graphic graphic = new Graphic(p,new SimpleMarkerSymbol(Color.RED,25,STYLE.CIRCLE));
gLayer.addGraphic(graphic);
map.addLayer(gLayer);
0 Kudos