The documentation for Google Maps for iOS states that:
Call one of several methods that allow you to animate the camera moving to a new location. You can control the duration of the animation with CoreAnimation.
For the life of me, I can't figure out how to control the animation duration. I have tried using UIView animations, like:
[UIView animateWithDuration: 5 animations:^{ GMSCameraPosition *camera = [self newCamera]; self.mapView.camera = camera; } completion:^(BOOL finished) { }];
And I have looked at CALayer animations in CoreAnimation. However, I don't know how you would apply a layer animation to the map view.
Can someone point me in the right direction please?
Cost and data. Google does not charge you to use the Google Maps app. Because Google Maps might use your phone or tablet's data connection, your mobile service provider might charge you for your data usage.
Type the name of a location or address. This displays a list of matching search results from Google Maps below the search bar at the top. Alternatively, you can tap the blue plus (+) icon in the lower-right corner of the map. Then tap Add new point. Drag the marker on the map to where you want to add a marker.
I found the answer ... you can control the animation duration by wrapping one of the animate* methods in a CATransaction, like this:
[CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat: 1.0f] forKey:kCATransactionAnimationDuration]; // change the camera, set the zoom, whatever. Just make sure to call the animate* method. [self.mapView animateToCameraPosition: [self newCamera]]; [CATransaction commit];
for Swift 3.0:
CATransaction.begin() CATransaction.setValue(1.5, forKey: kCATransactionAnimationDuration) // your camera code goes here, example: // mapView.animate(with: update) CATransaction.commit()
The bigger the value (1.5 in this case), the slower the animation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With