Skip to content
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

Show scale on map #6379

Merged
merged 7 commits into from
Sep 9, 2024
Merged

Show scale on map #6379

merged 7 commits into from
Sep 9, 2024

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Aug 28, 2024

Closes #6233

Why is this the best possible solution? Were any other approaches considered?

Both Mapbox and OSM have built-in scale bars, but Google Maps doesn’t. It’s strange because, as far as I know, this feature was available in earlier versions but was either removed or never added to newer ones. A scale bar is a basic UI element that should be included in any map engine, like a compass or zoom buttons. The Google Maps app does show a scale bar, so it seems the developers see its value, which makes it even more confusing why it’s missing from the Maps SDK. Interestingly, a scale bar has been added to the Compose version of Google Maps, as seen here: https://googlemaps.github.io/android-maps-compose/maps-compose-widgets/com.google.maps.android.compose.widgets/-scale-bar.html.

The issue with Google Maps is reported here: https://issuetracker.google.com/u/1/issues/35824009, and I’ve added my comment so they know there's more interest in this feature.

To fix the missing scale bar in Google Maps, I used this project: https://github.com/pengrad/MapScaleView. It seems to work well, is used by other developers, and looks similar to what the Google Maps app offers.

I thought about using this solution for all map engines, but I don’t think that’s the best idea because:

  • If the engines have their own scale bars, it’s better to use those and not worry about whether they work correctly.
  • I tried using that project with Mapbox and OSM, and even though it claims to work with other map engines, I noticed some differences when compared to their default scale bars.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

For Mapbox and OSM, it's sufficient to ensure the scale bar is displayed. However, as mentioned earlier, the Google Maps SDK doesn't offer a built-in scale bar, so I used a third-party library for this purpose. Please verify that it functions correctly and that the values displayed are accurate. Additionally, Google Maps required some minor adjustments to accommodate the scale bar, so please conduct a brief regression test on that map engine.

Do we need any specific form for testing your changes? If so, please attach one.

No.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 marked this pull request as ready for review August 28, 2024 11:28
@grzesiek2010 grzesiek2010 requested a review from seadowg August 28, 2024 11:28
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually thinking we shouldn't bother with the scale bar for Google Maps given it means pulling in another dependency - especially one that's not been updated for 4 years. Let's just do the OSM/Mapbox changes for now, and we can discuss whether adding scale to Google Maps is worth the risk of us maintaining it in the future in our next sync.

@grzesiek2010
Copy link
Member Author

According to our discussion with @lognaturel and @seadowg I've pulled out https://github.com/pengrad/MapScaleView into the google-maps module. I think it can be a part of that module instead of being a separate one since it's used only with google maps.

@grzesiek2010 grzesiek2010 requested a review from seadowg September 4, 2024 09:53
@WKobus
Copy link

WKobus commented Sep 6, 2024

Tested with Success

Verified on device with Android 14

Verified cases:

  • Scale bars in different geo questions / form map
  • All map sources
  • Offline layers
  • Regression check on maps
  • Rotating device
  • Don't keep activities on
  • No background processes

@srujner
Copy link

srujner commented Sep 9, 2024

Tested with Success

Verified on device with Android 10

@grzesiek2010 grzesiek2010 merged commit c7f5b15 into getodk:master Sep 9, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show scale on map
4 participants