You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: Add a ScaleBar composable component
* chore: Fix typo in docs
* docs: Add documentation in README
* docs: Tweak docs
* docs: Tweak docs
* chore: Make DarkGray public for ScaleBar configuration
For example, if users want to specify it or different colors based on isSystemInDarkTheme()
* docs: Tweak docs
* chore: Allow setting width and height
* refactor: Rename duration variable and change to Int
This more closely matches other compose duration parameters
* refactor: Convert unit conversion functions to extension functions
* refactor: ScaleBar into maps-compose-widgets package
* chore: Switch to local module so artifact is always tied to same version as maps-compose
Copy file name to clipboardExpand all lines: README.md
+36-1Lines changed: 36 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,6 +199,38 @@ and don't use `Marker` composables (unless you don't care about `onClick`
199
199
events). Clustering is the only use-case tested with `MapEffect`, there may be
200
200
gotchas depending on what features you use in the utility library.
201
201
202
+
## Widgets
203
+
204
+
This library also provides optional composable widgets in the `maps-compose-widgets` library that you can use alongside the `GoogleMap` composable.
205
+
206
+
### ScaleBar
207
+
208
+
This widget shows the current scale of the map in feet and meters when zoomed into the map, changing to miles and kilometers, respectively, when zooming out. A `DisappearingScaleBar` is also included, which appears when the zoom level of the map changes, and then disappears after a configurable timeout period.
209
+
210
+
The [ScaleBarActivity](app/src/main/java/com/google/maps/android/compose/ScaleBarActivity.kt) demonstrates both of these, with the `DisappearingScaleBar` in the upper left corner and the normal base `ScaleBar` in the upper right:
Both versions of this widget leverage the `CameraPositionState` in `maps-compose` and therefore are very simple to configure with their defaults:
215
+
216
+
```kotlin
217
+
ScaleBar(
218
+
modifier =Modifier
219
+
.padding(top =5.dp, end =15.dp)
220
+
.align(Alignment.TopEnd),
221
+
cameraPositionState = cameraPositionState
222
+
)
223
+
224
+
DisappearingScaleBar(
225
+
modifier =Modifier
226
+
.padding(top =5.dp, end =15.dp)
227
+
.align(Alignment.TopStart),
228
+
cameraPositionState = cameraPositionState
229
+
)
230
+
```
231
+
232
+
The colors of the text, line, and shadow are also all configurable (e.g., based on `isSystemInDarkTheme()` on a dark map). Similarly, the `DisappearingScaleBar` animations can be configured.
0 commit comments