简体   繁体   English

MapKit 中特定位置的海拔高度

[英]Altitude in MapKit from specific location

I've got an issue to get an altitude for specific location pointed on the Apple Map.我在获取 Apple 地图上指向的特定位置的高度时遇到了问题。 To obtain the altitude I use the following code:要获得高度,我使用以下代码:

self.touchPointLocation = CLLocation(latitude: newCoordinate.latitude, longitude: newCoordinate.longitude)
let altutide: CLLocationDistance = self.touchPointLocation.altitude

Every time I run the application on the device I get altitude for pointed location 0.0.每次我在设备上运行应用程序时,我都会获得指向位置 0.0 的高度。

Does anybody know how to get around this problem?有人知道如何解决这个问题吗?

I am pretty sure if you are indoors you cannot get altitude readings(indoors device uses cell tower/WIFI location).我很确定如果您在室内,则无法获得高度读数(室内设备使用手机信号塔/WIFI 位置)。 Try testing your code on a real device outdoors.尝试在户外的真实设备上测试您的代码。 You need the GPS reading to get an altitude reading.您需要 GPS 读数才能获得高度读数。

I had a similar problem with my code, drove me nuts(2-3 hours).我的代码也有类似的问题,让我发疯(2-3 小时)。 Then I was outside for a fag, tried again on real device.然后我在外面找了一个同性恋,在真实设备上再次尝试。 Poof, it worked.噗,成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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