Kuldeep Mishra
Kuldeep Mishra

Reputation: 4040

How To rotate Custom marker heading (Direction) of Mapbox map view

How can i change the direction (Heading) of the custom marker on Mapbox map on Swift. Here is my code

func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
    var annotationImage = mapView.dequeueReusableAnnotationImage(withIdentifier: "annotation")

    if annotationImage == nil {

        var image = UIImage(named: "mapdirection")!
        image = image.withAlignmentRectInsets(UIEdgeInsets(top: 0, left: 0, bottom: image.size.height/2, right: 0))

        annotationImage = MGLAnnotationImage(image: image, reuseIdentifier: "annotation")
    }
    return annotationImage
}

Upvotes: 5

Views: 522

Answers (0)

Related Questions