0
我正試圖顯示用戶的當前位置以及該地區附近的用戶。在iOS地圖中顯示若干註釋
我這樣做,顯示用戶的
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D(latitude:location!.coordinate.latitude ,longitude : location!.coordinate.longitude)
let span = MKCoordinateSpanMake(0.01,0.01)
let region = MKCoordinateRegion(center: center, span: span)
self.mapView.setRegion(region, animated: true)
self.manager.stopUpdatingLocation()
}
用戶 plotUsersonGraph(lat,longitude:long,title:"Apple HQ",subtitle:"Welcome to Apple")
func plotUsersonGraph(latitude:Double,longitude:Double,title:String,subtitle:String){
let HQlocation = CLLocationCoordinate2DMake(latitude, longitude)
let span = MKCoordinateSpanMake(0.01, 0.01)
let region = MKCoordinateRegion(center: HQlocation, span: span)
// self.mapView.setRegion(region, animated: true)**THIS IS CAUSING PROBLEM**
let annotation = MKPointAnnotation()
annotation.coordinate = HQlocation
annotation.title = title
annotation.subtitle = subtitle
self.mapView.addAnnotation(annotation)
}
我能夠單獨查看這兩個位置,但我無法合併到一起兩者繪製附近。 plotUsersonGraph
將同時在圖上添加多個用戶。