I want to show the location of an address in Google Maps.
How do I get the latitude and longitude of an address using the Google Maps API?
This is how you can find the latitude and longitude of where we have click on map.
public boolean onTouchEvent(MotionEvent event, MapView mapView)
{
//---when user lifts his finger---
if (event.getAction() == 1)
{
GeoPoint p = mapView.getProjection().fromPixels(
(int) event.getX(),
(int) event.getY());
Toast.makeText(getBaseContext(),
p.getLatitudeE6() / 1E6 + "," +
p.getLongitudeE6() /1E6 ,
Toast.LENGTH_SHORT).show();
}
return false;
}
it works well.
To get the location's address we can use geocoder class.