我正在使用swift創建地圖。我如何才能找到我在蘋果地圖上保存的當前位置的名稱,例如讓我說我在沃爾瑪,如何讓它打印出位置的名稱,以及它是否打印出地址。查找位置名稱swift地圖
我當前的代碼是
class MapVC: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
let manager = CLLocationManager()
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations[0]
let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01)
let mylocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
let region:MKCoordinateRegion = MKCoordinateRegionMake(mylocation, span)
map.setRegion(region, animated: true)
print(location.coordinate)
print(location.coordinate.latitude)
print(location.speed)
self.map.showsUserLocation = true
self.map.showsPointsOfInterest = true
}
override func viewDidLoad() {
super.viewDidLoad()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestAlwaysAuthorization()
manager.startUpdatingLocation()
}
[將座標轉換爲城市名稱?](https://stackoverflow.com/questions/27735835/convert-coordinates-to-city-name) – Emm