1

I'm working on an app where manual interaction with map is not allowed. The only way to change the map is as user is moving towards a direction. So if a user rotates the phone rotates and so based on the compass in iPhone the map should rotate automatically rather than user rotating it to the direction by 2 fingers gestures. Here is a picture that clear the idea a little more: enter image description here Consider the red dot as my location and as I rotate my phone I want google map to rotate with it. So my question is that how this can be achieved? As there is a method I found [_myMap animateToViewingAngle:45]; after searching but this didn't did what I was looking for.

EDIT I thought of this is there any way we can convert lat and long values to angle?

Community
  • 1
  • 1
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116
  • Please refer to my answer here http://stackoverflow.com/questions/38208747/gmsmapview-tracking-mode-heading/38209077#38209077 – Bharat Jul 17 '16 at 16:53

1 Answers1

3

You can use the course property from the CLLocation and pass it to the animateToBearing method of your GMSMapView. From the documentation:

Swift

var course: CLLocationDirection { get }

Objective-C

@property(readonly, nonatomic) CLLocationDirection course

Discussion

Course values are measured in degrees starting at due north and continuing clockwise around the compass. Thus, north is 0 degrees, east is 90 degrees, south is 180 degrees, and so on. Course values may not be available on all devices. A negative value indicates that the direction is invalid.

antonio
  • 18,044
  • 4
  • 45
  • 61