Convert latitude and longitude into esri arcGIS MapPoint

user1111781 picture user1111781 · Jan 10, 2012 · Viewed 9.5k times · Source

I am having trouble in converting the latitude and longitude values into android esri arcGIS map Point. Here's my code to get latitude and longitude values from GPS coordinates:

LocationManager lm;
String towers;
double lat;
double longi;
TextView txt;

            lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            Criteria crit = new Criteria();
            towers = lm.getBestProvider(crit, false);
            Location location = lm.getLastKnownLocation(towers);

            if(location != null)
            {
                lat = location.getLatitude();
                longi = location.getLongitude();
            }

now I have the latitude and longitude values. Now all I need is to convert these values into valid esri arcGIS MapPoint. Can anyone help me?

Thanks in advance.

Answer

Luke picture Luke · Jan 20, 2012

Assuming you're using the ESRI Android API? If so, create a graphics layer on your map. Then create a point object

com.esri.core.geometry.Point
Point myPoint = new Point();

then set the x/y values:

myPoint.setX(longi);
myPoint.setY(lat);

then add myPoint to the graphics object.

http://help.arcgis.com/en/arcgismobile/10.0/apis/android/api/index.html