In the Google Map SDK for iOS, how do I change the carrier map without animating it?

I can change the support of my card using

[googleMapView animateToBearing:0.5]; 

but how to do it so that the change is instant, without animation?

+4
source share
3 answers

Grab the current position of the camera, change the position of the bearing, then set the position of the viewing camera:

 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; 
+3
source

Since there is no direct choice, such as movetobearing, the above approach can be used. Another option is to use [googleMapView animateToBearing:0.5]; and then set the duration of the animation to a very low value, such as 0.0001f, which gives a visual motion effect

 [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat: 0.0001f] forKey:kCATransactionAnimationDuration]; [mapView_ animateToBearing:0.5]; [CATransaction commit]; 
+2
source

For a smoother and more transient update try this (view - GMSMapView)

 [self.view animateToCameraPosition:[GMSCameraPosition cameraWithLatitude:coordinate.latitude longitude:coordinate.longitude zoom:15 bearing:bearing viewingAngle:45]]; 
0
source

Source: https://habr.com/ru/post/1492394/


All Articles