Skip to content

Commit 5e09e75

Browse files
committed
Update map config for compass button
1 parent a6a6267 commit 5e09e75

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib-compose/src/main/java/com/what3words/components/compose/maps/W3WMapDefaults.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ object W3WMapDefaults {
4747
*
4848
* @property darkModeCustomJsonStyle The custom JSON style for dark mode
4949
* @property isBuildingEnable Whether 3D buildings are enabled on the map
50+
* @property isCompassButtonEnabled Whether the compass button is enabled on the map
5051
* @property gridLineConfig The configuration for grid lines on the map
5152
* @property buttonConfig The configuration for map control buttons
5253
*/
5354
@Immutable
5455
data class MapConfig(
5556
val darkModeCustomJsonStyle: String?,
5657
val isBuildingEnable: Boolean,
58+
val isCompassButtonEnabled: Boolean,
5759
val gridLineConfig: GridLinesConfig,
5860
val buttonConfig: ButtonConfig
5961
)
@@ -170,13 +172,15 @@ object W3WMapDefaults {
170172
*
171173
* @param darkModeCustomJsonStyle The custom JSON style for dark mode
172174
* @param isBuildingEnable Whether 3D buildings are enabled on the map
175+
* @param isCompassButtonEnabled Whether the compass button is enabled on the map
173176
* @param gridLineConfig The configuration for grid lines on the map
174177
* @param buttonConfig The configuration for map control buttons
175178
* @return A MapConfig instance with the specified parameters
176179
*/
177180
fun defaultMapConfig(
178181
darkModeCustomJsonStyle: String? = null,
179182
isBuildingEnable: Boolean = false,
183+
isCompassButtonEnabled: Boolean = true,
180184
gridLineConfig: GridLinesConfig = defaultGridLinesConfig(),
181185
buttonConfig: ButtonConfig = defaultButtonConfig(),
182186
): MapConfig {
@@ -185,6 +189,7 @@ object W3WMapDefaults {
185189
isBuildingEnable = isBuildingEnable,
186190
gridLineConfig = gridLineConfig,
187191
buttonConfig = buttonConfig,
192+
isCompassButtonEnabled = isCompassButtonEnabled
188193
)
189194
}
190195

lib-compose/src/main/java/com/what3words/components/compose/maps/providers/googlemap/W3WGoogleMap.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ fun W3WGoogleMap(
120120
contentPadding = layoutConfig.contentPadding,
121121
mapColorScheme = if (state.isDarkMode) ComposeMapColorScheme.DARK else ComposeMapColorScheme.LIGHT,
122122
uiSettings = MapUiSettings(
123+
compassEnabled = mapConfig.isCompassButtonEnabled,
123124
indoorLevelPickerEnabled = false,
124125
zoomControlsEnabled = false,
125126
myLocationButtonEnabled = false,

lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBox.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ fun W3WMapBox(
172172
)
173173
},
174174
compass = {
175-
Compass(
176-
modifier = Modifier.padding(layoutConfig.contentPadding)
177-
)
175+
if(mapConfig.isCompassButtonEnabled) {
176+
Compass(
177+
modifier = Modifier.padding(layoutConfig.contentPadding)
178+
)
179+
}
178180
},
179181
attribution = {
180182
Attribution(

0 commit comments

Comments
 (0)