我希望引脚的位置在敲击引脚时放大,以便位置位于中心.我不知道该怎么做.请帮我. 你想要做的事情有很多. 确定敲击了哪个引脚 将mapView置于攻丝针上 如果您在项目中正确启动了mapVi
>确定敲击了哪个引脚
>将mapView置于攻丝针上
如果您在项目中正确启动了mapView(以视图作为其委托),则可以使用mapView(_:didSelectAnnotationView:)方法完成上述两点,如下所示:
func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
// get the particular pin that was tapped
let pinToZoomOn = view.annotation
// optionally you can set your own boundaries of the zoom
let span = MKCoordinateSpanMake(0.5, 0.5)
// or use the current map zoom and just center the map
// let span = mapView.region.span
// now move the map
let region = MKCoordinateRegion(center: pinToZoomOn!.coordinate, span: span)
mapView.setRegion(region, animated: true)
}
此方法告诉委托(您的视图最有可能)选择了一个地图注释视图并移动(和/或缩放)到该坐标区域.
