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

Flickering: Modifying annotations in annotations manager causes remove and redraw #2249

Open
sravanporipireddy opened this issue Oct 7, 2024 · 4 comments
Labels
bug 🪲 Something is broken!

Comments

@sravanporipireddy
Copy link

Environment

  • Xcode version: 16.0
  • iOS version: 18.0
  • Devices affected: iPad
  • Maps SDK Version: 11.7.0

Observed behavior and steps to reproduce

Expected behavior

@sravanporipireddy sravanporipireddy added the bug 🪲 Something is broken! label Oct 7, 2024
@sravanporipireddy
Copy link
Author

I have a scenario where annotation array needs to be updated once every two seconds. When the array of annotations is updated the redraw should be smooth rather than clearing the annotations and redrawing them again.

var polygonAnnotations: [PolygonAnnotation] = [] var lineAnnotations: [PolylineAnnotation] = [] for drawables in explorationDrawableData.explorationDataDrawables { configureExplorationBlockPolygon( wgs84Coordinate: drawables, yaw: explorationDrawableData.yaw, polygonAnnotations: &polygonAnnotations, lineAnnotations: &lineAnnotations) } polygonAnnotationManager?.annotations = polygonAnnotations lineAnnotationManager?.annotations = lineAnnotations

@pjleonard37
Copy link
Contributor

Hi @sravanporipireddy -

Can you share a bit more about your use case:

  • How many annotations do you have?
  • What is the data source of these annotations?
  • Are you updating all of those annotations every 2 seconds, or just a few?
  • Can you share a video of this behavior?

We have multiple ways of handling annotations/markers on the map, so another approach may better suit your use case. You can learn more about the different approaches here: https://docs.mapbox.com/ios/maps/guides/markers-and-annotations/

@sravanporipireddy
Copy link
Author

flickering.mov

How many annotations do you have? -> Could be in thousands
What is the data source of these annotations? -> One dimensional array of centroids
Are you updating all of those annotations every 2 seconds, or just a few? -> All of them
Can you share a video of this behavior? -> Shared

In the recording which i shared you can observe whenever we update the polygons in annotation manager the entire drawing is removed first and then redrawn with latest polygons.

@pjleonard37
Copy link
Contributor

Hi @sravanporipireddy --

Thanks for sharing these additional details. In your case, I think using Style Layers makes more sense than using annotations. With this approach you add both a Source, which contains geographic data, and a Layer, which contains styling information, to the map. You can style this Layer according to your needs, in this case to create small polygons. We have more information on working with Sources and Layers here. I'd also recommend looking at our iOS examples here for inspiration. These examples are relevant to your implementation: feature state and draw geometries.

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