How to find user coordinates in Yandex Map kit?

1.6k Views Asked by At

How to find user coordinates in YandexMapkit?

I use the Location class and prescribe

private Location location;
location.getPosition();

but it is empty.

1

There are 1 best solutions below

0
On BEST ANSWER

you should look at the repository: https://github.com/yandex/mapkit-ios-demo - there are a lot of useful samples. Here is how I do if I want to get user location in iOS app:

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

mapView - is YMKMapView! from storyboard.

Of course you should also ask permissions from user and add to info.plist "Privacy - Location When In Use Usage Description".