我的理解是,它不是那麼簡單 -
你需要創建一個區域 - 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