我的理解是,它不是那么简单 -
你需要创建一个区域 - MKCoordinateRegion
获取长期和纬度使用MKCoordinateSpan
例如:
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {
//Get the location you need the span zoom
let location = CLLocationCoordinate2D(
//getPropertyLocation.latitude/longitude already set to CLLocationDegrees in a prior process.
latitude: self.getPropertyLocation.latitude ,
longitude: self.getPropertyLocation.longitude
)
// Get the span that the mapView is set to by the user. "propertyMapView" is the MKMapView in this example.
let span = self.propertyMapView.region.span
// Setup the region based on the lat/lon of the property and retain the span that already exists.
let region = MKCoordinateRegion(center: location, span: span)
//Center the view with some animation.
mapView.setRegion(region, animated: true)
}
“拉长”的错误。如何将它们设置为用户位置? – Adam
你可以硬编码当前的经纬度,如果你在模拟器上测试,你需要自己设置。 –
我如何硬拉代码和长?难吗? – Adam