Ios Google maps keep current location course(angle

2019-02-27 12:09发布

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 ?

0条回答
登录 后发表回答