I need to make a marker that can rotate automatically like the direction of the phone. Please, can anyone help me to do this? I'm creating like Uber marker, so the marker should be a car. Thank you
            Asked
            
        
        
            Active
            
        
            Viewed 1,232 times
        
    -1
            
            
        - 
                    4What have you tried so far? – Tim Aug 14 '18 at 07:53
 - 
                    i try to create like Uber application, i need the marker to be like marker on Uber application – Bilal Maarbani Aug 14 '18 at 07:54
 - 
                    1@BilalMaarbani, TimH's question is more like, what specific code have you tried? – Daniel Aug 14 '18 at 07:55
 - 
                    do you mean what is the language i used to create this application ? if yes i write it by swift 4 – Bilal Maarbani Aug 14 '18 at 07:57
 - 
                    There are already many solutions available on google, why didn't you search first. If you have any specific issue then ask. – dahiya_boy Aug 14 '18 at 07:57
 - 
                    @BilalMaarbani You are new, so first read this https://stackoverflow.com/help/how-to-ask – dahiya_boy Aug 14 '18 at 07:59
 - 
                    i was search too many but i didn't find my answer, i need to rotate the marker automatically like the direction of the user – Bilal Maarbani Aug 14 '18 at 07:59
 - 
                    i edit the post, please see the image link that i uploaded to post, thank you all guys – Bilal Maarbani Aug 14 '18 at 08:02
 - 
                    here is your solution https://stackoverflow.com/questions/48394319/custom-annotation-move-animation-ios-swift-like-ola-uber-app-mapkit-swift?rq=1 – dahiya_boy Aug 14 '18 at 08:02
 - 
                    @dahiya_boy this is mapkit not google map api, thank you for helping me – Bilal Maarbani Aug 14 '18 at 08:04
 - 
                    please any one can help me ? – Bilal Maarbani Aug 14 '18 at 08:22
 - 
                    Have you really searched the internet? https://stackoverflow.com/questions/36450526/rotate-gmsmarker-in-direction-at-which-user-facing .. This one mentions uber also in the question.. – Skywalker Aug 14 '18 at 08:59
 - 
                    Possible duplicate of [Rotate GMSMarker in direction at which user facing](https://stackoverflow.com/questions/36450526/rotate-gmsmarker-in-direction-at-which-user-facing) – Skywalker Aug 14 '18 at 09:00
 - 
                    https://www.udemy.com/advanced-ios-firebae-build-an-uber-clone-app/ maybe this tutorial will help you but you need to buy. – Wings Aug 14 '18 at 09:11
 - 
                    @Skywalker thank you for your replying, yes i search too many on the internet, this link you implemented have no right answer , what can i do ? – Bilal Maarbani Aug 14 '18 at 09:15
 - 
                    @V_rohit thank you for your reply, i will check it thank you – Bilal Maarbani Aug 14 '18 at 09:21
 - 
                    Try the answers that have been upvoted.. Please research more about stackoverflow.. – Skywalker Aug 15 '18 at 03:02
 - 
                    Right answers are not the only correct answers. Other answers may work just as well, or in some cases even better than the answer marked as correct. – Skywalker Aug 15 '18 at 03:03
 
1 Answers
1
            i found the solution by myself..
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
    let direction = newHeading.magneticHeading
    let radians = -direction / 180.0 * .pi
    let angle = SupportFunc.radiansToDegress(radians: CGFloat(radians))
    DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
        self.mapView.animate(toBearing: CLLocationDirection(-angle))
    }
}
static func radiansToDegress(radians: CGFloat) -> CGFloat {
    return radians * 180 / CGFloat(Double.pi)
}
        Bilal Maarbani
        
- 11
 - 6
 
- 
                    
 - 
                    SupportFunc is a base class. we call the static method using the class name. – Ramkumar Dec 19 '21 at 10:16