進口的UIKit 進口MapKit 進口CoreLocation
類secondViewController:UIViewController中,CLLocationManagerDelegate,MKMapViewDelegate {
@IBOutlet var mapview: MKMapView!
// VAR的LocationManager = CLLocationManager(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()*/
肯定會是不錯的一大量的代碼來演示這裏的技術! –