Reputation: 1950
I tried all the animation methods provided by google maps. But I fail to animate the zoomlevel of map view. I have tried mapView.animateToZoom(15). Also
UIView.animateWithDuration(5.0, animations: {
let zoomIn = GMSCameraUpdate.zoomTo(15)
self.mapView.animateToZoom(15)
})
But I fail to achieve the animation. I also followed GMSMapView animateToCameraPosition zoom in - zoom out animation
But no hope. Can anyone help please?
Upvotes: 2
Views: 2602
Reputation: 831
Update for swift 5
CATransaction.begin()
CATransaction.setValue(1.0, forKey: kCATransactionAnimationDuration)
let city = GMSCameraPosition.camera(withTarget: CLLocationCoordinate2D(latitude, longitude:logitude), zoom: 16)
self.mapView.animate(to: city)
CATransaction.commit()
Upvotes: 2
Reputation: 1950
After a lot of struggle I managed to animate the GMSMapView: Here is the code for the reference:
mapView.camera = GMSCameraPosition.cameraWithLatitude(58.998400,longitude: 10.035604, zoom: 1)
CATransaction.begin()
CATransaction.setValue(2.0, forKey: kCATransactionAnimationDuration)
let city = GMSCameraPosition.cameraWithLatitude(58.998400,longitude: 10.035604, zoom: 15)
self.mapView.animateToCameraPosition(city)
CATransaction.commit()
Upvotes: 6