0

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

我使用 Location 类并规定

private Location location;
location.getPosition();

但它是空的。

4

1 回答 1

1

您应该查看存储库: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 “隐私 - 使用时的位置使用说明”。

于 2020-04-05T13:18:38.953 回答