Skip to content

Commit ebe2c8d

Browse files
authored
Merge pull request #112 from what3words/fix/Update-public-functions-for-implement-with-existing-map
Public functions for case user integrate with existing map
2 parents 21ff15c + 28ee7a2 commit ebe2c8d

8 files changed

Lines changed: 22 additions & 20 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class W3WMapManager(
379379
*
380380
* @param newCameraState The new camera state to set.
381381
*/
382-
internal suspend fun updateCameraState(newCameraState: W3WCameraState<*>) = withContext(IO) {
382+
suspend fun updateCameraState(newCameraState: W3WCameraState<*>) = withContext(IO) {
383383
_mapState.update {
384384
it.copy(
385385
cameraState = newCameraState,
@@ -1846,7 +1846,7 @@ class W3WMapManager(
18461846
*
18471847
* @param textDataSource The text data source implementation to use for API calls.
18481848
*/
1849-
internal fun setTextDataSource(textDataSource: W3WTextDataSource) {
1849+
fun setTextDataSource(textDataSource: W3WTextDataSource) {
18501850
this.textDataSource = textDataSource
18511851
}
18521852

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fun W3WGoogleMap(
159159
* @param gridLinesConfig Configuration for the grid lines, including scale factor
160160
* @param onCameraBoundUpdate Callback that receives the calculated grid bounds and visible bounds
161161
*/
162-
private suspend fun updateCameraBound(
162+
suspend fun updateCameraBound(
163163
projection: Projection,
164164
gridLinesConfig: W3WMapDefaults.GridLinesConfig,
165165
onCameraBoundUpdate: (gridBound: W3WRectangle, visibleBound: W3WRectangle) -> Unit

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ fun W3WGoogleMapDrawMarkers(
375375
) {
376376
val drawZoomIn = remember(zoomLevel) {
377377
derivedStateOf {
378-
zoomLevel > zoomSwitchLevel && zoomLevel >= MIN_SUPPORT_GRID_ZOOM_LEVEL_GOOGLE
378+
zoomLevel >= zoomSwitchLevel && zoomLevel >= MIN_SUPPORT_GRID_ZOOM_LEVEL_GOOGLE
379379
}
380380
}
381381

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fun W3WMapBox(
270270
* The grid bound is scaled according to the configuration, while the visible bound
271271
* represents the actual visible area on the map.
272272
*/
273-
private fun updateGridBound(
273+
fun updateGridBound(
274274
mapboxMap: MapboxMap,
275275
gridLinesConfig: W3WMapDefaults.GridLinesConfig,
276276
onCameraBoundUpdate: (gridBound: W3WRectangle, visibleBound: W3WRectangle) -> Unit,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fun W3WMapBoxDrawMarkers(
285285
) {
286286
val drawZoomIn = remember(zoomLevel) {
287287
derivedStateOf {
288-
zoomLevel > zoomSwitchLevel && zoomLevel >= MIN_SUPPORT_GRID_ZOOM_LEVEL_MAP_BOX
288+
zoomLevel >= zoomSwitchLevel && zoomLevel >= MIN_SUPPORT_GRID_ZOOM_LEVEL_MAP_BOX
289289
}
290290
}
291291

lib-compose/src/main/java/com/what3words/components/compose/maps/state/camera/W3WCameraState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import com.what3words.core.types.geometry.W3WRectangle
1818
@Immutable
1919
interface W3WCameraState<T> {
2020

21-
val cameraState: T
21+
var cameraState: T
2222

2323
var gridBound: W3WRectangle?
2424

lib-compose/src/main/java/com/what3words/components/compose/maps/state/camera/W3WGoogleCameraState.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class W3WGoogleCameraState(initialCameraState: CameraPositionState) :
3535
const val MY_LOCATION_ZOOM = 20f
3636
}
3737

38-
override val cameraState: CameraPositionState by mutableStateOf(initialCameraState)
38+
override var cameraState: CameraPositionState by mutableStateOf(initialCameraState)
3939

4040
override var gridBound: W3WRectangle? by mutableStateOf(null)
4141

@@ -74,18 +74,20 @@ class W3WGoogleCameraState(initialCameraState: CameraPositionState) :
7474
override suspend fun moveToPosition(
7575
listLatLng: List<W3WCoordinates>,
7676
) {
77-
val latLngBounds = LatLngBounds.Builder()
78-
listLatLng.forEach {
79-
latLngBounds.include(LatLng(it.lat, it.lng))
80-
}
77+
if (listLatLng.isNotEmpty()) {
78+
val latLngBounds = LatLngBounds.Builder()
79+
listLatLng.forEach {
80+
latLngBounds.include(LatLng(it.lat, it.lng))
81+
}
8182

82-
withContext(Main) {
83-
cameraState.animate(
84-
update =
85-
CameraUpdateFactory.newLatLngBounds(
86-
latLngBounds.build(), 10
87-
)
88-
)
83+
withContext(Main) {
84+
cameraState.animate(
85+
update =
86+
CameraUpdateFactory.newLatLngBounds(
87+
latLngBounds.build(), 10
88+
)
89+
)
90+
}
8991
}
9092
}
9193

lib-compose/src/main/java/com/what3words/components/compose/maps/state/camera/W3WMapboxCameraState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class W3WMapboxCameraState(initialCameraState: MapViewportState) :
3232
const val MY_LOCATION_ZOOM = 20.0
3333
}
3434

35-
override val cameraState: MapViewportState by mutableStateOf(initialCameraState)
35+
override var cameraState: MapViewportState by mutableStateOf(initialCameraState)
3636

3737
override var gridBound: W3WRectangle? by mutableStateOf(null)
3838

0 commit comments

Comments
 (0)