11package com.what3words.components.compose.maps
22
3- import android.Manifest
43import android.graphics.PointF
4+ import android.view.View
5+ import android.widget.RelativeLayout
56import androidx.compose.foundation.layout.Box
67import androidx.compose.foundation.layout.padding
78import androidx.compose.runtime.Composable
@@ -18,8 +19,8 @@ import androidx.compose.ui.Modifier
1819import androidx.compose.ui.geometry.Rect
1920import androidx.compose.ui.layout.boundsInParent
2021import androidx.compose.ui.layout.onGloballyPositioned
21- import com.google.accompanist.permissions.ExperimentalPermissionsApi
22- import com.google.accompanist.permissions.rememberMultiplePermissionsState
22+ import androidx.compose.ui.platform.LocalView
23+ import androidx.core.view.doOnLayout
2324import com.what3words.components.compose.maps.W3WMapDefaults.MapColors
2425import com.what3words.components.compose.maps.W3WMapDefaults.defaultMapColors
2526import com.what3words.components.compose.maps.buttons.MapButtons
@@ -314,6 +315,8 @@ internal fun W3WMapContent(
314315 onMapViewPortProvided : (W3WGridScreenCell ) -> Unit ,
315316 onRecallButtonPositionProvided : ((PointF ) -> Unit ),
316317) {
318+ val view = LocalView .current
319+
317320 var bounds by remember { mutableStateOf(Rect .Zero ) }
318321
319322 // Check if the map is initialized, use to prevent LaunchedEffect to re-run on configuration changes
@@ -376,6 +379,24 @@ internal fun W3WMapContent(
376379 }
377380 }
378381
382+ // Reposition Google Map compass to align with app's design
383+ LaunchedEffect (mapProvider, mapConfig.isGoogleCompassAlignedRight) {
384+ if (mapProvider == MapProvider .GOOGLE_MAP && mapConfig.isGoogleCompassAlignedRight) {
385+ val compass = view.findViewWithTag<View >(" GoogleMapCompass" )
386+
387+ compass?.doOnLayout {
388+ val params = compass.layoutParams as RelativeLayout .LayoutParams
389+ params.addRule(RelativeLayout .ALIGN_PARENT_START , 0 )
390+ params.addRule(RelativeLayout .ALIGN_PARENT_END )
391+ params.addRule(RelativeLayout .ALIGN_PARENT_TOP )
392+
393+ compass.layoutParams = params
394+ compass.requestLayout()
395+ }
396+ }
397+ }
398+
399+
379400 Box (
380401 modifier = modifier
381402 .onGloballyPositioned { coordinates ->
@@ -443,7 +464,7 @@ internal fun W3WMapView(
443464 onMarkerClicked : ((W3WMarker ) -> Unit ),
444465 onMapClicked : ((W3WCoordinates ) -> Unit ),
445466 onCameraUpdated : (W3WCameraState <* >) -> Unit ,
446- onMapProjectionUpdated : ((W3WMapProjection ) -> Unit )? = null,
467+ onMapProjectionUpdated : ((W3WMapProjection ) -> Unit )? = null,
447468) {
448469 when (mapProvider) {
449470 MapProvider .GOOGLE_MAP -> {
0 commit comments