diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt b/maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt index de7e25f2..8fb34907 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt @@ -175,6 +175,8 @@ private fun MapLifecycle(mapView: MapView) { onDispose { lifecycle.removeObserver(mapLifecycleObserver) context.unregisterComponentCallbacks(callbacks) + mapView.onDestroy() + mapView.removeAllViews() } } } @@ -195,7 +197,9 @@ private fun MapView.lifecycleObserver(previousState: MutableState this.onResume() Lifecycle.Event.ON_PAUSE -> this.onPause() Lifecycle.Event.ON_STOP -> this.onStop() - Lifecycle.Event.ON_DESTROY -> this.onDestroy() + Lifecycle.Event.ON_DESTROY -> { + //handled in onDispose + } else -> throw IllegalStateException() } previousState.value = event