Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show an arrow on mapview showing the driving direction

I want to show an arrow image on GMSMapView(i am using google maps sdk). Now if i am driving(arrow is showing my current location) and i have to take left turn then i have to change bearing of mapView. But i have no idea how to do this.

I am trying to change bearing in didUpdateHeading

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{
if(newHeading.headingAccuracy>0)
{

    float heading = newHeading.magneticHeading; //in degrees
     //heading = (heading*M_PI/180);
    //NSLog(@"heading=%f", heading);
    [mapView animateToBearing:heading];
}}

headingFilter is set to 12.

I have also tried trueHeading, but magneticHeading is giving better results not accurate though.
Please help.

like image 424
Virat Naithani Avatar asked Dec 02 '13 07:12

Virat Naithani


People also ask

How do I turn on arrows in Google Maps?

Tap the blue Live View button (it's right next to the Start button). Now when you start walking toward your destination, large arrows and the street name will appear on your screen to guide you.

Why does Google Maps show dot instead of arrow?

Now, the search giant has replaced the direction arrow on the blue dot with a beam to help you know the accuracy of the direction shown by the app.

What is a direction arrow on a map?

A small cross or arrow in the map tells us the direction of North. A north arrow (sometimes also called a compass rose) is a figure displaying the main directions, North, South, East and West.

What does the little arrow mean on Google Maps?

The 'arrowhead' is not a compass per se, although it is called 'compass mode'. It's meant for the map to face whatever direction you're facing.


1 Answers

You don't actually need to convert anything to degrees. The newHeading object you get from your delegate method should be enough. The GMS-reference for the animateToBearing: requires a CLLocationDirection as a parameter. The newHeading.magneticHeading or newHeading.trueHeading provided by the delegate method is an object of this type. Also: you're converting the newHeading to a float, where as a CLLocationDirection is a double, so the GMS-function will also require a double. See reference.

like image 158
Martijn Avatar answered Oct 12 '22 22:10

Martijn