Ios Google maps keep current location course(angle) always north like google Navigation
Asked Answered
F

0

2

I'm using google maps to track

func ShowcurrentMarker()
{
    currentlocationCoordinate = CLLocationCoordinate2DMake(LatestLocation.coordinate.latitude, LatestLocation.coordinate.longitude)

    if(CurrentLocationMarker == nil)
    {

        CurrentLocationMarker = GMSMarker(position:currentlocationCoordinate)
        CurrentLocationMarker.map = self.mapView
        CurrentLocationMarker.icon = UIImage.init(named:"car_icon")
        mapView.camera = GMSCameraPosition.camera(withTarget: CLLocationCoordinate2DMake(LatestLocation.coordinate.latitude, LatestLocation.coordinate.longitude), zoom: 15.0)

    }
    else
    {
        CATransaction.begin()
        CATransaction.setAnimationDuration(2)
        CurrentLocationMarker.position = currentlocationCoordinate
          CurrentLocationMarker.rotation = CLLocationDirection.abs(LatestLocation.course)
        mapView.camera = GMSCameraPosition.camera(withTarget: CLLocationCoordinate2DMake(LatestLocation.coordinate.latitude, LatestLocation.coordinate.longitude), zoom:mapView.camera.zoom)
                CATransaction.commit()

    }
}

Here is my working code. Now I want my car always to keep on north facing like navigation app.

How can I do that ?

Footy answered 24/4, 2017 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.