Search code examples
iosgoogle-maps-sdk-ios

In Google Map SDK for IOS, how do I change the bearing of the map without animating it?


I can change the bearing of my map using

[googleMapView animateToBearing:0.5];

but how does one do this so the change is instantaneous, with no animation?


Solution

  • Grab the current camera position, change the bearing, then set the view's camera position:

    GMSCameraPosition *myCamera = googleMapView.camera;
    GMSCameraPosition *myNewCamera = [GMSCameraPosition cameraWithLatitude:myCamera.targetAsCoordinate.latitude longitude:myCamera.targetAsCoordinate.longitude zoom:myCamera.zoom bearing:0.5 viewingAngle:myCamera.viewingAngle];
    googleMapView.camera = myNewCamera;