I'm working on a project in which I need to move my GMSMarker on map like uber app does. The problem I'm facing on crossroads were I need to change the heading as well as bearing(rotation) at the end of road.
I want my marker should move like:

I'm using following line of code for moving marker from location P1 to P2 but it's giving direct distance(purple path). How can I find intermediate coordinate i.e. meeting point as well as the distance from P1 to vertex(meeting point) where I need to turn the car marker in the direction of P2
self.Last_Location= last locaiton of car (P1)
self.Current_Location= current location of car (P2)
and I'm getting location update in every "6 seconds"
	
	
	
		
	
		
			
		
		
	
				
			I want my marker should move like:
- Car first move P1 to vertex point(meeting point)
- Then it'll turn towards point P2 and
- Finally will move form meeting point to P2

I'm using following line of code for moving marker from location P1 to P2 but it's giving direct distance(purple path). How can I find intermediate coordinate i.e. meeting point as well as the distance from P1 to vertex(meeting point) where I need to turn the car marker in the direction of P2
self.Last_Location= last locaiton of car (P1)
self.Current_Location= current location of car (P2)
and I'm getting location update in every "6 seconds"
		Code:
	
	   func animateCarMovementonMapWithMarker(){
        let bearing:double= self.getHeadingForDirectionFromCoordinate(Last_Location, toCoordinate:
            Current_Location)
        let p1:MKMapPoint=MKMapPointForCoordinate(self.Last_Location)
        let p2:MKMapPoint=MKMapPointForCoordinate(self.Current_Location)
        let dist:CLLocationDistance=MKMetersBetweenMapPoints(p1, p2)
        CATransaction.begin()
        CATransaction.setAnimationDuration(6.0)
        self.carMarker.position = self.Last_Location
        self.carMarker.position = self.Current_Location
        self.carMarker.rotation = bearing
        CATransaction.commit()
        self.driver_Last_Location = self.Current_Location
    }
			
				Last edited by a moderator: