The problem was that we kept the same instance of the mapView across configuration changes. Therefore, when switching the theme, the mapView already had a parent view which causes an IllegalStateException. To fix this, I recreate the mapView at every configuration change. This has the side effect of re-centering the map at every configuration change. To avoid this, I save the camera position every time it moves, so I can restore the previous camera position when the map is recreated. Closes #333.
The problem was that we kept the same instance of the
mapView
across configuration changes. Therefore, when switching the theme, themapView
already had a parent view which causes anIllegalStateException
. To fix this, I recreate themapView
at every configuration change. This has the side effect of re-centering the map at every configuration change. To avoid this, I save the camera position every time it moves, so I can restore the previous camera position when the map is recreated. Closes #333.