From 5ef236072d757d5614db629201fe01d72fcadf7e Mon Sep 17 00:00:00 2001 From: scharron Date: Mon, 18 May 2026 10:27:17 +0200 Subject: [PATCH] Fix layout issue where MarkerViews disappear When width = 0 and height = 0, View has no dimension yet. Wait for the next layout before addViewAnnotation --- .../rnmbx/components/annotation/RNMBXMarkerView.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerView.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerView.kt index e4fa86b339..ee4ee25635 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerView.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerView.kt @@ -119,7 +119,13 @@ class RNMBXMarkerView(context: Context?, private val mManager: RNMBXMarkerViewMa mMapView?.offscreenAnnotationViewContainer?.addView(view) mMapView?.offscreenAnnotationViewContainer?.removeView(view) } - + + if (view.width == 0 || view.height == 0) { + // Fixes https://github.com/rnmapbox/maps/issues/4206 + // Wait for the next layout via onLayoutChange + return + } + val options = getOptions() val content = view as? RNMBXMarkerViewContent; @@ -209,4 +215,4 @@ class RNMBXMarkerView(context: Context?, private val mManager: RNMBXMarkerViewMa } // endregion -} \ No newline at end of file +}