我必须在地图视图中显示5个点(在Array中)。我在我的日志中显示了Array值.Loop运行完美,并且没有添加注释。这是我的代码:
self.mapView.delegate = self
self.mapView.mapType = MKMapType.standard
self.mapView.isZoomEnabled = true
self.mapView.isScrollEnabled = true
self.mapView.showsUserLocation = true
print("LOCATION LIST==>>")
print(items["Location"].arrayValue)
for locationList in items["Location"].arrayValue
{
print(locationList)
let annotation = MKPointAnnotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: locationList["latitude"].doubleValue, longitude: locationList["longitude"].doubleValue)
self.mapView.addAnnotation(annotation)
}
self.mapView.delegate = self
日志:
LOCATION LIST==>>
{
"Latitude" : 12.988415,
"Longtitude" : 80.218386
}, {
"Latitude" : 12.988445,
"Longtitude" : 80.21839199999999
}, {
"Latitude" : 12.988492,
"Longtitude" : 80.218422
}, {
"Latitude" : 12.988558,
"Longtitude" : 80.218461
},
{
"Latitude" : 12.991181,
"Longtitude" : 80.21950200000001
}
但它没有在我的地图View.Thanks中显示Annotations。