Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ViewAnnotation does not stick on the map while fast moving the map #4659

Open
QuangBinhDinh opened this issue May 24, 2024 · 0 comments
Labels
bug Something isn’t working

Comments

@QuangBinhDinh
Copy link

Mapbox Navigation SDK version

2.18

Steps to reproduce

I created some custom UIView and make it as ViewAnnotation , then add them to NavigationMapView

 class SampleClass {
    let navigationMapView: NavigationMapView!
    let navigationViewController: NavigationViewController!
     ...
 func renderWaypoints (points: [CLLocationCoordinate2D] , forSimulating : Bool = false) {
        let alphabet = Array("SABCDEFGHIJKLMNOPQRSTUVWXYZ").map {String($0)}
        for (index ,point) in points.enumerated() {
            let size = 25.0
            let roundView = UIView()
            roundView.frame = CGRect(x: 0, y: 0, width: size, height: size)
            roundView.backgroundColor = index == 0 ? #colorLiteral(red: 0.5843137503, green: 0.8235294223, blue: 0.4196078479, alpha: 1) : #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
            roundView.layer.cornerRadius = size / 2// Half of the width/height to make it round
            roundView.layer.borderColor = index == 0 ? #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) : #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
            roundView.layer.borderWidth = 1.5
            
            let label = UILabel()
            label.frame = CGRect(x: 0, y: 0, width: size, height: size)
            label.text = alphabet[index]
            label.textAlignment = .center
            label.textColor = index == 0 ? .white : .darkGray
            label.font = UIFont.systemFont(ofSize: 13, weight: UIFont.Weight.bold)
            
            roundView.addSubview(label)
            do {
                if !forSimulating {
                    try navigationMapView.mapView.viewAnnotations.add(roundView, id:"Annotation_\(index)", options: ViewAnnotationOptions(geometry: Point(point), width: size, height: size))
                }
                else {
                    try navigationViewController.navigationMapView?.mapView.viewAnnotations.add(roundView, id:"Annotation_\(index)", options: ViewAnnotationOptions(geometry: Point(point), width: size, height: size))
                }
                
            }
            catch {
                print("Cannot add annotation")
            }
        }
 }

While testing on simulator (iPhone 15 Pro, XCode 15.3), I see no problem. But when I switch to an iPhone 7 real device to testing, annotations start to drift a bit while moving the map fast. You can see at video below

rpreplay-final1716542967_vfGPbTxV.mov

Before implementing this custom waypoint, I already clone the example project https://github.com/mapbox/mapbox-navigation-ios-examples and read the example code about custom waypoints. However for some reasons, my code do not use showcase method of NavigationMapView, therefore I cannot implement appropriate function like the example.

Expected behavior

ViewAnnotation must be stick on the coordinates given , even when user moves a map

Actual behavior

ViewAnnotation drift its position when user moves a map

Is this a one-time issue or a repeatable issue?

one-time

@QuangBinhDinh QuangBinhDinh added the bug Something isn’t working label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

No branches or pull requests

1 participant