每当位置更新时我都会添加注释,但它不适用于模拟器。
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
print("my Current location is \(location?.coordinate.latitude) ")
let center = CLLocationCoordinate2D(latitude: (location?.coordinate.latitude)!, longitude: (location?.coordinate.longitude)!)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.mapView.setRegion(region, animated: true)
let myCurrentLocation = MKPointAnnotation()
myCurrentLocation.coordinate=center
myCurrentLocation.title = "Where I am"
myCurrentLocation.subtitle = "Here I am"
self.mapView .addAnnotation(myCurrentLocation)
}