diff --git a/play-services-maps/core/mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/InfoWindow.kt b/play-services-maps/core/mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/InfoWindow.kt index 16f0471d8b..b9514a17d8 100644 --- a/play-services-maps/core/mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/InfoWindow.kt +++ b/play-services-maps/core/mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/InfoWindow.kt @@ -39,7 +39,12 @@ import kotlin.math.* */ fun IInfoWindowAdapter.getInfoWindowViewFor(marker: IMarkerDelegate, mapContext: MapContext): View? { - getInfoWindow(marker).unwrap()?.let { return it } + getInfoWindow(marker).unwrap()?.let { view -> + return view.apply { + // Remove any previous parents mistakenly added by the client + parent?.let { (it as ViewManager).removeView(this) } + } + } getInfoContents(marker).unwrap()?.let { view -> // Detach from previous BubbleLayout parent, if exists @@ -95,7 +100,7 @@ class InfoWindow internal constructor( /** * Close this [InfoWindow] if it is visible, otherwise calling this will do nothing. * - * @param silent `OnInfoWindowCloseListener` is only called if `silent` is not `false` + * @param silent `OnInfoWindowCloseListener` is only called if `silent` is `false` */ fun close(silent: Boolean = false) { if (isVisible) {