问题
I have a method (seen below) which zooms into an annotation which was tapped.
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
print("Tapped")
mapView.showAnnotations(pointAnnotations, animated: true)// this does the zooming
mapView.deselectAnnotation(annotation, animated: false)
}
This works, however, I dont like the way it zooms. (currently it, as soon as you tap, starts zooming then somewhat lagging behind it begins to center the object until it gets to the correct position. At which point it abruptly stops)
How Can I change this to emulate Snapmaps zoom?
I believe what happens in their zoom is that the zoom begins a little after the centering begins and this all happens much faster. Additionally, the stopping is not as sudden. I believe Its like ease in thing.
回答1:
What I did is I used the following to make the zoom look much better. Check out here for more info and other versions of this zoom.
let cam2 = mapView.cameraThatFitsShape(object.polyline!, direction: 0.0, edgePadding: .init(top: 20, left: 30, bottom: 100, right: 30))
mapView.fly(to: cam2, withDuration: 0.25, completionHandler: nil)
来源:https://stackoverflow.com/questions/54683669/how-can-i-change-a-showannotation-zoom-using-mapbox-for-ios