在快速中设置放大



在我的应用程序中,我有一个mapkit视图,当应用程序启动时,它会放大到用户位置mapView.setUserTrackingMode(MKUserTrackingMode.follow, animated: true),但是当我运行此代码时,它会放大到用户位置,但我想更靠近用户位置。我该怎么做?

您可以根据需要设置regionRadius

let regionRadius: CLLocationDistance = 1000
func centerMapOnLocation(_ location: CLLocation) {
let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, regionRadius, regionRadius)
mapView.setRegion(coordinateRegion, animated: true)
}

其中location.coordinate是要放大的坐标。

最新更新