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

Annotations seem empty #197

Closed
emretekince opened this issue Mar 21, 2021 · 2 comments
Closed

Annotations seem empty #197

emretekince opened this issue Mar 21, 2021 · 2 comments
Labels
bug 🪲 Something is broken!

Comments

@emretekince
Copy link

Environment

  • Xcode version: 12.4
  • iOS version: 14
  • Devices affected:
  • Maps SDK Version: 10.0.0-beta.15

Observed behavior and steps to reproduce

Annotations are added on styleFullyLoaded event but it shows empty after 10 sec of runtime.

`struct Map: UIViewRepresentable {
var myPlaneCoords: CLLocationCoordinate2D

private let mapView = MapView(with: .zero, resourceOptions:  ResourceOptions(accessToken: "xxx"), styleURL: .custom(url: URL(string: "xxx")!))


func makeUIView(context: UIViewRepresentableContext<Map>) -> MapView {
    print("makeUIView")
    mapView.cameraManager.setCamera(to: CameraOptions(center: myPlaneCoords, zoom: 14))
    DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
        print("annotations delayed", mapView.annotationManager.annotations)
    }
    mapView.on(.mapLoadingFinished) { (event) in
        print("mapLoadingFinished")
        let res =  mapView.annotationManager.addAnnotation(myPlane)
        print(res)
    }
    
    mapView.on(.styleLoadingFinished) { (event) in
        print("styleLoadingFinished")
    }
    
    mapView.on(.styleFullyLoaded) { (event) in
        print("styleFullyLoaded")
        let res =  mapView.annotationManager.addAnnotation(myPlane)
        print(res)
    }
    
    
    mapView.update { (mapOptions) in
        mapOptions.ornaments.showsScale = false
    }
    
    return mapView
}

}
`
Console output
styleLoadingFinished
styleFullyLoaded
success(true)
styleFullyLoaded
failure(MapboxMaps.AnnotationManager.AnnotationError.annotationAlreadyExists(Optional("Annotation has already been added.")))
mapLoadingFinished
failure(MapboxMaps.AnnotationManager.AnnotationError.annotationAlreadyExists(Optional("Annotation has already been added.")))
annotations delayed [:]

Expected behavior

Annotations shouldn't be empty

Notes / preliminary analysis

Sometimes it shows them in delayed function maybe I'm adding them in the wrong event?

Additional links and references

@emretekince emretekince added the bug 🪲 Something is broken! label Mar 21, 2021
@emretekince emretekince changed the title Annotations seems empty Annotations seem empty Mar 21, 2021
@macdrevx
Copy link
Contributor

Hi @emretekince, thanks for sharing this feedback.

Can you try only adding the annotation on the .mapLoadingFinished event to see if that fixes the issue?

Also, it looks like you're using SwiftUI, so you might be interested in our SwiftUI example if you haven't already seen it.

@macdrevx
Copy link
Contributor

macdrevx commented Apr 1, 2021

This is probably due to the issue fixed in #246

This will go out in our next release. @emretekince if you're using SPM or CocoaPods and would like to try out the fix, you can point to commit c10c571 and give it a try. Please reopen this issue if you find that it's still happening (either in the next release or when using that commit).

@macdrevx macdrevx closed this as completed Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something is broken!
Projects
None yet
Development

No branches or pull requests

2 participants