輸入のUIKit 輸入MapKit 輸入CoreLocation
クラスsecondViewController:のUIViewController、CLLocationManagerDelegate、MKMapViewDelegate {
@IBOutlet var mapview: MKMapView!
// VARのlocationmanager = CLLocationManager()
let locationManager = CLLocationManager()
var currentLocation: CLLocation!
/*パブリックFUNCのlocationManager(_マネージャ:CLLocationManager、didUpdateLocations場所:[CLLocation]){
let location = locations[0]
let span = MKCoordinateSpanMake(0.1, 0.1)
let my = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
print(my)
let region = MKCoordinateRegionMake(my, span)
mapview.setRegion(region, animated: true)
self.mapview.showsUserLocation = true
}*/
override func viewDidLoad() {
super.viewDidLoad()
/* mapview.mapType = MKMapType.standard
locationmanager.delegate = self
locationmanager.desiredAccuracy = kCLLocationAccuracyBest
locationmanager.requestWhenInUseAuthorization()
/* isAuthorizedtoGetUserLocation()
if CLLocationManager.locationServicesEnabled() {
locationmanager.delegate = self
locationmanager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
}*/
locationmanager.startUpdatingLocation()*/
確かに持っていいだろうここの技術を実証するコードの塊! –