出于某种原因,我的市场不会放大到当地。事实上,无论我改变什么,它都不会改变变焦。我是在代码的错误部分加载它,还是我错过了其他的东西?任何帮助表示赞赏。
我的代码是:
@IBOutlet var here: MKMapView!
var locationManager: CLLocationManager?
var selectedItem: String?
func locationManager
(manager: CLLocationManager!,didUpdateToLocation newLocation: CLLocation!,
fromLocation oldLocation: CLLocation!){
manager.desiredAccuracy = kCLLocationAccuracyBest
var region = self.here.region as MKCoordinateRegion
self.here.setRegion(region, animated: true)
region.span.longitudeDelta = 0.0144927536
region.span.latitudeDelta = 0.0144927536
}
答案 0 :(得分:23)
我相信你需要在设置区域之前设置lat和long。 setRegion函数是放大特定部分的函数,缩放级别取决于您的范围。这是缩放地图的示例。
let span = MKCoordinateSpanMake(0.075, 0.075)
let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: lat, longitude: long), span: span)
mapView.setRegion(region, animated: true)