简体   繁体   中英

convert latitude and longitude value to double

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.

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM