Reputation: 29
I have Code: LatLng latLng = new LatLng(-7.11231243, 110.45345433);
How can I take each value latitude and longitude?
I want to convert like this;
double lat = -7.11231243;
double lng = 110.45345433;
Can anyone help, please.
Upvotes: 0
Views: 1711
Reputation: 417
You can directly get the value of latitude and longitude from LatLng object.
`public final class LatLng
public final double latitude
Latitude, in degrees. This value is in the range [-90, 90].
public final double longitude
Longitude, in degrees. This value is in the range [-180, 180).`
You need to call this :
double lat = latlng.latitude;
double lng = latlng.longitude;
Upvotes: 1
Reputation: 44854
You can access the class fields directly, they are public
double lat = latLng.latitude;
see https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng
Upvotes: 3