androidyandexyandex-mapkit

How to find user coordinates in Yandex Map kit?


How to find user coordinates in YandexMapkit?

I use the Location class and prescribe

private Location location;
location.getPosition();

but it is empty.


Solution

  • 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".