MapBox turn by turn navigation Custom Marker Issue

2019-08-18 02:27发布

I am using navigation view for my application, I wan to load n number markers on navigation view with different marker images. When I tried to do this with navigation annotation view only destination image is changed others shown as 1,2,3 etc. I tried to load image using this function

func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? {
let reuseIdentifier = "\(annotation.coordinate)"
let annotationView1 = MGLAnnotationView(reuseIdentifier: reuseIdentifier)
if let castAnnotation = annotation as? CustomPointAnnotation {
    annotationView1.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
    let  imageV = UIImageView(frame: (annotationView1.frame))
        imageV.contentMode = .center
    imageV.image = UIImage(named: castAnnotation.image!)
    annotationView1.addSubview(imageV)
}
return annotationView1

}enter image description here

0条回答
登录 后发表回答