Skip to content

Commit ad59069

Browse files
authored
Fix layout issue where MarkerViews disappear (#4212)
When width = 0 and height = 0, View has no dimension yet. Wait for the next layout before addViewAnnotation
1 parent 49df61c commit ad59069

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerView.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ class RNMBXMarkerView(context: Context?, private val mManager: RNMBXMarkerViewMa
127127
mMapView?.offscreenAnnotationViewContainer?.addView(view)
128128
mMapView?.offscreenAnnotationViewContainer?.removeView(view)
129129
}
130-
130+
131+
if (view.width == 0 || view.height == 0) {
132+
// Fixes https://github.com/rnmapbox/maps/issues/4206
133+
// Wait for the next layout via onLayoutChange
134+
return
135+
}
136+
131137
val options = getOptions()
132138

133139
val content = view as? RNMBXMarkerViewContent;
@@ -217,4 +223,4 @@ class RNMBXMarkerView(context: Context?, private val mManager: RNMBXMarkerViewMa
217223
}
218224

219225
// endregion
220-
}
226+
}

0 commit comments

Comments
 (0)