私はここで少し立ち往生しています...
マップボックス ビューのマーカーごとに異なる画像を追加しようとしています。マップを作成するために、配列を調べる for ループを使用しました。
for arrayInterest in dicoInterest {
let point = MGLPointAnnotation()
var latitudePoint : Double
var longitudePoint : Double
var typePoint : String
latitudePoint = (arrayInterest["latitude"] as! Double)
longitudePoint = (arrayInterest["longitude"] as! Double)
typePoint = (arrayInterest["type"] as! String)
point.coordinate = CLLocationCoordinate2D(latitude: latitudePoint, longitude: longitudePoint)
mapView.addAnnotation(point)
print("latitude : \(latitudePoint)")
print("longitude : \(longitudePoint)")
print("point : \(point)")
print("type : \(typePoint)")
}
ここまでは順調ですね。問題は、オンラインで見つけた特定の画像を追加する唯一の方法は次のとおりです。
func mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {
var annotationImage = mapView.dequeueReusableAnnotationImageWithIdentifier(typePoint)
var image = UIImage(named: typePoint)
image = image?.imageWithAlignmentRectInsets(UIEdgeInsetsMake(0, 0, image!.size.height/2, image!.size.width/2))
annotationImage = MGLAnnotationImage(image: image!, reuseIdentifier:"\(point)")
return annotationImage
}
それをループの外側に追加するため、各マーカーでは機能しません。
それを行う別の方法はありますか?