Add a custom marker in mapbox in a for loop
<p>I'm a little bit stuck here… </p>

<p>I'm trying to add a different image for each marker in my mapbox view. To populate the map I used a for loop that look into an array : </p>

<pre><code>    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)")


    }
</code></pre>

<p>So far so good. The problem is, the only way to add a specific image I found looking online was this : </p>

<pre><code>func mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -&gt; 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
}
</code></pre>

<p>I add to put that outside the loop, and therefore, it doesnt work for each marker. </p>

<p>Is there another way to do that ?</p>