From 027a6cdb95deeb09229eed8f94ed1e59a0ce82bc Mon Sep 17 00:00:00 2001 From: DaVinci9196 Date: Thu, 24 Oct 2024 20:40:35 +0800 Subject: [PATCH] Fix CameraPosition NullPointerException --- .../hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt index aa5911f805..60c3159c8a 100644 --- a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt +++ b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt @@ -102,7 +102,9 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) this.view = object : FrameLayout(mapContext) {} } - override fun getCameraPosition(): CameraPosition? = map?.cameraPosition?.toGms() + override fun getCameraPosition(): CameraPosition { + return map?.cameraPosition?.toGms() ?: CameraPosition(LatLng(0.0, 0.0), 0f, 0f, 0f) + } override fun getMaxZoomLevel(): Float = toHmsZoom(map?.maxZoomLevel ?: 18.toFloat()) override fun getMinZoomLevel(): Float = toHmsZoom(map?.minZoomLevel ?: 3.toFloat())