Rotate GMSMarker in direction at which user facing
We can rotate image based on course property CLLocation Class
let marker = GMSMarker(position: currentLocation!)
let head = locationManager.location?.course ?? 0
marker.rotation = head
marker.icon = UIImage(named: "testyCar.png")
marker.map = mapView
Current location 'CLLocation' object has a property called 'course'
@property(readonly, nonatomic) CLLocationDirection course;
of type CLLocationDirection(typedef of double) which is an angle of the location.
For car to rotate, You need extra field in your backend, direction, along with latitude and longitude. Use this information to rotate car by applying Transform on UIView
CGAffineTransformMakeRotation(M_PI * (course_of_location) / 180.0);