IOS提供CLGeocoder將地址轉成經緯度,或是把經緯度轉換成地址,詳細語法如下
- 記得先Import MapKit
- 地址轉經緯度(geocodeAddressString) ```swift
let geoCoder = CLGeocoder()
geoCoder.geocodeAddressString(“這邊帶入地址”, completionHandler: {
(placemarks:[AnyObject]!,error:NSError!) -> Void in
if error != nil{
}println(error) return
if placemarks != nil && placemarks.count > 0{
})let placemark = placemarks[0] as CLPlacemark //placemark.location.coordinate 取得經緯度的參數 }
1 |
|