MKMapView, how to calculate the height in meters?

How can I calculate the height (height from sea level) of the center of my map view (which is not the user's current location), in meters?

We can see this indication, for example, in Google Earth:

Google earth image

+4
source share
3 answers

What about

mapView.camera.altitude 

@property (non-atomic) CLLocationDistance altitude

Height above ground, measured in meters.

IOS Availability (7.0 and later)

Announced in MKMapCamera.h Link Link to the MKMapCamera class

+3
source

As far as I know, Apple does not provide an API for determining the height of the coordinate. Google has an elevation API that you can use to do this. You can access it through the HTTP interface and get the location height as a JSON response.

Run the following query to get the mark 39.7391536, -104.9847034:

 http://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&sensor=false 

Then you will get a JSON response like this

 { "results" : [ { "elevation" : 1608.637939453125, "location" : { "lat" : 39.73915360, "lng" : -104.98470340 }, "resolution" : 4.771975994110107 } ], "status" : "OK" } 

The full Elevation API is described here https://developers.google.com/maps/documentation/elevation/

+2
source

CLLocation comes with the height of the current deviation

+1
source

Source: https://habr.com/ru/post/1482539/


All Articles