我正在尝试向我的地图添加注释。 我有一个包含坐标的点数组。 我正在尝试从这些坐标中添加注释。
我已经定义了以下内容:
var points: [CLLocationCoordinate2D] = [CLLocationCoordinate2D]()
let annotation = MKPointAnnotation()
这些点都有坐标,我已经确认过了。接下来我执行以下操作:
for index in 0...points.count-1 {
annotation.coordinate = points[index]
annotation.title = "Point \(index+1)"
map.addAnnotation(annotation)
}
它只添加了最后一个注释...而不是所有的注释。 为什么会这样呢? 顺便问一下,有没有办法按标题删除指定的注释?
map.annotations
数组,直到找到该注释。然后调用map.removeAnnotation(annotation)
。 - zisoft