尝试使用我自己的图像作为“pin”,我有大约4个不同的图像。因为我使用了很多coords,这是“叠加它们”的好方法 提前谢谢。
代码如下:
struct Location {
let title: String
let subtitle: String
let imageName: String
let latitude: Double
let longitude: Double
}
let locations = [
Location(title: "ben", subtitle: "The big", imageName: "de.png", latitude: 56.888214, longitude: 14.779658),
Location(title: "adam", subtitle: "bervesiell", imageName: "be.png", latitude: 56.588224, longitude: 14.779658),
Location(title: "david", subtitle: "Downfall", imageName: "ce.png", latitude: 56.888214, longitude: 14.579668)
]
for location in locations {
let annotation = MKPointAnnotation()
annotation.title = location.title
annotation.subtitle = location.subtitle
annotation.imageName = location.imageName
annotation.coordinate = CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
Mapview.addAnnotation(annotation)
}
}