Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Latitude and Longitude on Map in Android?

How can I get the Latitude and Longitude values of a particular location that I have long clicked on the map in Android?

like image 267
Praveen Avatar asked Dec 15 '10 04:12

Praveen


People also ask

How do I show latitude and longitude on Google Maps?

On your computer, open Google Maps. Right-click the place or area on the map. This will open a pop-up window. You can find your latitude and longitude in decimal format at the top.

Is there a latitude longitude app for Android?

Use the Google Maps Mobile App to Find Coordinates You can also use the Google Maps mobile app for Android, iPhone, and iPad to locate the exact GPS coordinates for any location worldwide.


1 Answers

For the long click, I suggest you check out http://www.kind-kristiansen.no/2010/handling-longpresslongclick-in-mapactivity/. This will go into detail on how to listen for long click events within the Maps API since there is little or no built-in functionality that I know of.

As for the lat/lng code, after you get the long click you can translate the pixels to coordinates.

public void recieveLongClick(MotionEvent ev)
{
    Projection p = mapView.getProjection();
    GeoPoint geoPoint = p.fromPixels((int) ev.getX(), (int) ev.getY());
    // You can now pull lat/lng from geoPoint
}
like image 103
Vetsin Avatar answered Oct 11 '22 13:10

Vetsin