Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ class RNMBXImage(private val mContext: ReactApplicationContext, private val mMan
// region add/remove to Map
fun addToMap(mapView: RNMBXMapView) {
mMapView = mapView

// The child view is usually inserted before we know the map: the child is mounted into
// this view before this view is mounted into RNMBXImages, so addView() above ran while
// mMapView was still null and the child was not placed anywhere. A view that is in no
// hierarchy is never attached to a window, and a Drawee controller only submits its
// request on attach - so an <Image> inside the child never loads, and the bitmap we
// capture shows everything except that image. Place the child now that the map is known.
val childView = mChildView
if (childView != null && childView.parent == null) {
mapView.offscreenAnnotationViewContainer?.addView(childView)
}
}
// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ class RNMBXImages(context: Context, private val mManager: RNMBXImagesManager) :
return style != null && imageId?.let { style.getStyleImage(it) } != null
}

/**
* Give the map to an image view that was mounted after this component was added to the map.
*
* addToMap only visits the views present at that moment, and the view manager does not pass
* the map to a later child, so such a child would never place its own child view and never
* register an image.
*/
fun attachImageViewIfOnMap(image: RNMBXImage) {
mMapView?.let { image.addToMap(it) }
}

override fun addToMap(mapView: RNMBXMapView) {
super.addToMap(mapView)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) :

parent.mImageViews.add(childPosition, childView)
childView.nativeImageUpdater = parent
parent.attachImageViewIfOnMap(childView)
}

override fun removeView(parent: RNMBXImages, view: View) {
Expand Down