Question

I have just completed an Android app, where I used bearing value of current location. Now I am trying to do same app for iOS. But did not find a way to get bearing of current location in iOS sdk?

I am not looking how to calculate bearing between two CLLocationCoordinate2Ds (Calculating bearing between two CLLocationCoordinate2Ds).

*** I need bearing of current location.

Any help will be great for me.

Was it helpful?

Solution

CLLocation has a course property (type CLLocationDirection) which is the bearing. From the docs:

Course values are measured in degrees starting at due north and continuing clockwise around the compass. Thus, north is 0 degrees, east is 90 degrees, south is 180 degrees, and so on. Course values may not be available on all devices. A negative value indicates that the direction is invalid.

OTHER TIPS

I know that this question is old but I will leave my answer that may help other people who pass by here.

class MapViewController: GMSMapViewDelegate {

    func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {

        self.bearing = position.bearing
    }
}

Using this delegate you can obtain the bearing related with camera rotation from the google maps SDK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top