如何在 Yandex 地图套件中查找用户坐标?

How to find user coordinates in Yandex Map kit?

如何在 YandexMapkit 中查找用户坐标?

我使用位置 class 并开处方

private Location location;
location.getPosition();

但它是空的。

你应该看看存储库:https://github.com/yandex/mapkit-ios-demo - 有很多有用的示例。 如果我想在 iOS 应用程序中获取用户位置,我会怎么做:

    let mapKit = YMKMapKit.sharedInstance()
    let userLocationLayer = mapKit.createUserLocationLayer(with: mapView.mapWindow)
    userLocationLayer.setVisibleWithOn(true)
    userLocationLayer.isHeadingEnabled = true

mapView - 是YMKMapView!从故事板。

当然你也应该征求用户的许可并添加到info.plist "Privacy - Location When In Use Usage Description".