Ios 为什么地图上只显示一个注释?
我试图在地图上显示多个位置,但最后它只显示地图上的最后一点 你能帮我吗 多谢各位Ios 为什么地图上只显示一个注释?,ios,swift,maps,Ios,Swift,Maps,我试图在地图上显示多个位置,但最后它只显示地图上的最后一点 你能帮我吗 多谢各位 var annotationArray : [MKPointAnnotation] = [] override func viewDidLoad() { super.viewDidLoad() let distanceSpan :CLLocationDegrees = 2000 haritaView?.showsUserLocation = true let points =
var annotationArray : [MKPointAnnotation] = []
override func viewDidLoad() {
super.viewDidLoad()
let distanceSpan :CLLocationDegrees = 2000
haritaView?.showsUserLocation = true
let points = [
["title": "New York, NY", "latitude": 41.044185, "longitude": 29.00734829999999],
["title": "Los Angeles, CA", "latitude": 41.031493, "longitude": 28.982564300000035],
["title": "Chicago, IL", "latitude": 41.0511273, "longitude": 28.992835199999945]
]
for point in points {
let annotation = MKPointAnnotation()
annotation.title = point["title"] as? String
annotation.coordinate = CLLocationCoordinate2D(latitude: point["latitude"] as! Double, longitude: point["longitude"] as! Double)
self.annotationArray.append(annotation)
}
print(self.annotationArray.count)
dump(self.annotationArray)
haritaView.addAnnotations(annotationArray)
for point in self.annotationArray {
self.haritaView.addAnnotation(point as MKAnnotation)
}
}
您的代码显示了所有3个注释,您确定要缩小吗?