Swift
1import UIKit 2import MapKit 3import CoreLocation 4 5class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate { 6 7 8 @IBOutlet weak var mapView: MKMapView! 9 @IBOutlet weak var addressLabel: UILabel! 10 11 12 override func viewDidLoad() { 13 super.viewDidLoad() 14 15 mapView.delegate = self 16 17 let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) 18 let location = CLLocationCoordinate2D(latitude: 36.6895000, longitude: 139.6917100) 19 20 let region = MKCoordinateRegion(center: location, span: span) 21 mapView.setRegion(region, animated: true) 22 23 24 25 } 26 27 func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { 28 let currentLocation = mapView.centerCoordinate 29 let location = CLLocation(latitude: currentLocation.latitude, longitude: currentLocation.longitude) 30 geoCode(location: location) 31 32 } 33 34 func geoCode(location: CLLocation){ 35 LocationManager.sharedInstance.reverseGeocodeLocationWithCoordinates(coord: location) { (reverseGecodeInfo, placemark, error) in 36 guard let info = reverseGecodeInfo else{ return} 37 print(info) 38 } 39 } 40 41 } 42
上記のコードにより、MAPの中心点の住所や緯度経度といった情報をコンドールに表示したいです。
ビルドすると100個以上のエラーが返ってきます。
大抵は[FIX]で修正できましたが、以下のエラーがBiuldTime上に出ており、解決できません。
Type 'LocationManagerDelegate' has no member 'locationManagerVerboseMessage'
Type 'LocationManagerDelegate' has no member 'locationManagerVerboseMessage'
'parseAppleLocationData' is inaccessible due to 'private'
'parseAppleLocationData' is inaccessible due to 'private' protection level
Cannot convert value of type '([CLPlacemark]?, NSError?) -> Void' to expected argument type 'CLGeocodeCompletionHandler' (aka '(Optional<Array<CLPlacemark>>, Optional<Error>) -> ()')
Type 'CharacterSet' has no member 'URLQueryAllowedCharacterSet'
Type 'CharacterSet' has no member 'URLQueryAllowedCharacterSet'
'parseGoogleLocationData' is inaccessible due to 'private' protection level
'getAddressDictionary' is inaccessible due to 'private' protection level
'getPlacemark' is inaccessible due to 'private' protection levelprotection level
足りない情報がありましたら、お申し付けください。