I am trying to get latitude and longitude on the Googlemap v2.. I have set the onclick listener for mapragment object using the code
map.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng latln) {
// TODO Auto-generated method stub
String s=latln.toString();
Log.w("dsfdsf",""+s);
}
});
It provides be the latitude and longitude coordinates in the format lat/lng: (xx.xxxxxx,yy.yyyyy) I need the exact method to get latitude and longitude data.. I dont want to parse the data using split and get the coordinates..
For newer version please use:
as
latlng.latitude
andlatlng.longitude
orlatlng.lat()
andlatlng.lng()
will give compilation error.To get Latitude and Longitude your have to declare 2 double variables.
This can easily be found in the Google Maps API reference:
So in your example you should call:
This is what I have done. The res contains the value of (lat,long).
This is for Android solution