I am trying to determine the height from a certain point, but I am not getting it using my iPad. I determined my height var as follows:
var altitude: CLLocationDistance = 0.0
I created this function:
func getAltitude(latitude: CLLocationDistance, longitude: CLLocationDistance) -> CLLocationDistance {
locationManager.requestWhenInUseAuthorization()
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.desiredAccuracy = kCLLocationAccuracyBest
let touchPointLocation = CLLocation(latitude: latitude, longitude: longitude)
let altitude = touchPointLocation.altitude
return altitude
}
For example, when I touch the map, I tried to get such a height, inside longpress:
let touchPoint = gestureRecognizer.location(in: self.map)
let coord = map.convert(touchPoint, toCoordinateFrom: self.map)
let altitude = getAltitude(latitude: coord.latitude, longitude: coord.longitude)
print(altitude)
Why is this wrong? How can i do this?
source
share