Select to view content in your preferred language

Get GeoPoint from Press on Screen

825
1
Jump to solution
01-16-2013 06:14 AM
GSauers
Frequent Contributor
I am trying to get the longitude and latitude of a point I mark on my map with a long press. Currently on a long press I get an icon to display where I press on the map using a MapPoint, but I want to get and display the Geo location of the point. Below is some of the code I use for handling a long press:

public void onLongPress(MotionEvent e){
     Point p = mapView.toMapPoint(new Point(e.getX(), e.getY()));

I than create a graphic and add it to the graphics layer. But using this information I need to convert the Point to a GeoPoint. Thank you in advance for any help.
0 Kudos
1 Solution

Accepted Solutions
GSauers
Frequent Contributor
Found the answer within another thread.


public void onLongPress(MotionEvent e){

Point geo = (Point) GeometryEngine.project(mapView.toMapPoint(e.getX(), e.getY()), mapView.getSpatialReference(), SpatialReference.create(4326));
double latitude = geo.getY();
double longitude = geo.getX();

Hope this helps others in the future.

View solution in original post

0 Kudos
1 Reply
GSauers
Frequent Contributor
Found the answer within another thread.


public void onLongPress(MotionEvent e){

Point geo = (Point) GeometryEngine.project(mapView.toMapPoint(e.getX(), e.getY()), mapView.getSpatialReference(), SpatialReference.create(4326));
double latitude = geo.getY();
double longitude = geo.getX();

Hope this helps others in the future.
0 Kudos