New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add a ScaleBar composable widget #157
Conversation
For example, if users want to specify it or different colors based on isSystemInDarkTheme()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some minor comments in the PR and one comment around introducing a new package for this and potentially future components/widgets in the future. I strongly recommend that we go this route to keep maps-compose
purely for core features which keeps the dependencies used at a minimal.
I was initially going to suggest to add a new composable lambda in the GoogleMap
composable for widgets like this since the ScaleBar
doesn't really make sense outside of the context of a GoogleMap
. Something like:
GoogleMap(
top = {
ScaleBar(/* ... */)
}
)
But, I think if we introduce a separate package for this widget then we should go with the current approach you have.
maps-compose/build.gradle
Outdated
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'com.google.android.gms:play-services-maps:18.0.2' | ||
implementation 'com.google.maps.android:maps-ktx:3.3.0' | ||
implementation 'com.google.maps.android:maps-ktx:3.4.0' | ||
implementation 'com.google.maps.android:maps-utils-ktx:3.3.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit wary to add a new dependency like the utility library to maps-compose
as it should be kept as lightweight as possible (ideally it should only contain Compose dependencies + the Maps SDK). How about creating a separate package for it? Something like maps-compose-widgets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes a lot of sense to me. I like "widgets" as well, so maps-compose-widgets
sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arriolac For configuring and publishing the artifact, can I duplicate most of what's in the maps-compose
build.gradle
(changing package names as appropriate)? Does other configuration need to happen to make this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you can duplicate what's in there. Publishing code is on the project-level build.gradle
file. You will have to make a new entry for artifactId
so that it's applied to the new module. See: https://github.com/googlemaps/android-maps-compose/blob/main/build.gradle#L24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done in 32e5a4e. Eyes on this are welcome to make sure I didn't miss anything.
maps-compose/src/main/java/com/google/maps/android/compose/components/ScaleBar.kt
Outdated
Show resolved
Hide resolved
maps-compose/src/main/java/com/google/maps/android/compose/components/ScaleBar.kt
Outdated
Show resolved
Hide resolved
maps-compose/src/main/java/com/google/maps/android/compose/components/ScaleBar.kt
Outdated
Show resolved
Hide resolved
maps-compose/src/main/java/com/google/maps/android/compose/components/ScaleBar.kt
Outdated
Show resolved
Hide resolved
This more closely matches other compose duration parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more comment to address and one suggestion (can be addressed in the same PR or separately).
maps-compose-widgets/build.gradle
Outdated
|
||
dependencies { | ||
implementation "androidx.compose.foundation:foundation:$compose_version" | ||
implementation 'com.google.maps.android:maps-compose:2.2.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should reference the local module so the artifact is always tied to the same version as maps-compose
.
implementation project(':maps-compose')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 33990bb
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'com.google.android.gms:play-services-maps:18.0.2' | ||
implementation 'com.google.maps.android:maps-ktx:3.4.0' | ||
implementation 'com.google.maps.android:maps-utils-ktx:3.3.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: dependencies shared across modules should be defined in a separate gradle file so there is one version used by both artifacts. doesn't have to be addressed now but something for future reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I opened #160 for this.
…ion as maps-compose
# [2.5.0](v2.4.0...v2.5.0) (2022-06-29) ### Features * Add a ScaleBar composable widget ([#157](#157)) ([8e6e0e6](8e6e0e6))
🎉 This PR is included in version 2.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This PR refactors the work done in PR googlemaps/android-maps-ktx#175 to use android-maps-compose instead of relying on the
GoogleMap
object.It creates a
ScaleBar
composable that 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. ADisappearingScaleBar
is also implemented, which imitates the scale bar behavior in the Google Maps app that appears when the zoom level of the map changes, and then disappears after a configurable timeout period.A new
ScaleBarActivity
demonstrates both of these, with theDisappearingScaleBar
in the upper left corner and the normalScaleBar
in the upper right (wait for the pause to see the left bar disappear):Usage
Both components leverage the
CameraPositionState
in maps-compose and therefore are very simple to configure with their defaults:Other configuration options
The colors of the text, line, and shadow are also all configurable (e.g., based on
isSystemInDarkTheme()
on a dark map) - here's the composable signature:Similarly, the
DisappearingScaleBar
animations can be configured:EDIT - This widget is going to be added in a new package
maps-compose-widgets
, and therefore needs another dependency as well:Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes googlemaps/android-maps-utils#701 🦕