Wun
Wun

Reputation: 6381

How to get Altitude from Latitude and Longitude or Google Map in Android?

I am implement Google Map in Android , and I got the Latitude and the Longitude via onMapClick like the following code.

public void onMapClick(LatLng latLng) {
    Log.d(TAG,"latLng.latitude = " + latLng.latitude);
    Log.d(TAG,"latLng.longitude = " + latLng.longitude);
}

But it did not have Altitude data.

Q1: How to get the Altitude of position which I click on the Google Map?

or

Q2: How to get the Altitude via known Latitude and Longitude ?

Thanks in advance.

Upvotes: 2

Views: 5818

Answers (2)

josedlujan
josedlujan

Reputation: 5600

Use the method Location.getAltitude()

Upvotes: 1

Scott Kronheim
Scott Kronheim

Reputation: 772

You can make an HTTP call to the Google Maps Elevation API, documented at https://developers.google.com/maps/documentation/elevation/intro. I don't believe that there is native Android client library for this API. You can make a request including latitude/longitude and receive elevation information in the response.

Upvotes: 1

Related Questions