Skip to content

Fix layout issue where MarkerViews disappear#4212

Open
scharron wants to merge 1 commit into
rnmapbox:mainfrom
scharron:patch-3
Open

Fix layout issue where MarkerViews disappear#4212
scharron wants to merge 1 commit into
rnmapbox:mainfrom
scharron:patch-3

Conversation

@scharron
Copy link
Copy Markdown
Contributor

When width = 0 and height = 0, sometimes View has no dimension yet. Wait for the next layout before addViewAnnotation

Description

Fixes #4206

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

When width = 0 and height = 0, View has no dimension yet.
Wait for the next layout before addViewAnnotation
Copilot AI review requested due to automatic review settings May 18, 2026 08:29
@scharron scharron deployed to CI with Mapbox Tokens May 18, 2026 08:29 — with GitHub Actions Active
@scharron scharron temporarily deployed to CI with Mapbox Tokens May 18, 2026 08:29 — with GitHub Actions Inactive
@scharron scharron temporarily deployed to CI with Mapbox Tokens May 18, 2026 08:29 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a guard to avoid creating marker annotation options when the underlying view hasn’t been laid out yet (width/height = 0), addressing a reported rendering issue.

Changes:

  • Early-return when the marker view has zero width/height to wait for a subsequent layout.
  • Adds an inline reference to the GitHub issue describing the problem.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +122 to +128

if (view.width == 0 || view.height == 0) {
// Fixes https://github.com/rnmapbox/maps/issues/4206
// Wait for the next layout via onLayoutChange
return
}

mMapView?.offscreenAnnotationViewContainer?.removeView(view)
}


Comment on lines +122 to +128

if (view.width == 0 || view.height == 0) {
// Fixes https://github.com/rnmapbox/maps/issues/4206
// Wait for the next layout via onLayoutChange
return
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: On Android, MarkerView sometimes disappear

2 participants