How can I change a showAnnotation zoom using mapbox for iOS?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 06:46:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!