简体   繁体   English

iOS swift:从日历条目的 event.structuredLocation 获取位置

[英]iOS swift : get location from event.structuredLocation of calendar entry

I evaluate calendar data and would have liked to continue using the data in CLLoation format, but with:我评估日历数据并希望继续使用 CLLoation 格式的数据,但具有:

    po structuredLocation! .geoLocation! .value (forKey: "course") or similar

do I not get the latitude / longitude?我没有得到纬度/经度吗? How does it work?它是如何工作的?

    func getLocationOfEvent(event: EKEvent, eventLocation: inout CLLocation?) 
    -> String {
      var structuredLocation: EKStructuredLocation?
    
      if event.location != nil {
        structuredLocation = event.structuredLocation
        eventLocation = event.structuredLocation!.geoLocation
      }
    
      if event.location == nil {
        return "<<<Location>>>"
    } else {
        return event.location!    /// String
    }
}

and from debugger: (lldb) po structuredLocation!.geoLocation!来自调试器:(lldb)postructuredLocation!.geoLocation! <+50.123456,+8.123456> +/- 0.00m (speed -1.00 mps / course -1.00) @ 25.09.20, 18:57:08 Mitteleuropäische Sommerzeit <+50.123456,+8.123456> +/- 0.00m(速度 -1.00 mps / course -1.00)@ 25.09.20, 18:57:08 Mitteleuropäische Sommerzeit

How does it work?它是如何工作的? Or Who knows how to do that?或者谁知道怎么做? Grateful for any help感谢任何帮助

You will find latitude, longitude, altitude and other info from EKEventStructuredLocation.您可以从 EKEventStructuredLocation 中找到纬度、经度、海拔高度和其他信息。

if event.location != nil {
    structuredLocation = event.structuredLocation
    print(event.structuredLocation?.geoLocation?.coordinate.latitude)
    print(event.structuredLocation?.geoLocation?.coordinate.longitude)
    print(event.structuredLocation?.geoLocation?.altitude)
        
  }

Add this properties to your CLLocation Object and you are good to go...将此属性添加到您的 CLLocation 对象,您就可以开始了...

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

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