KEMBAR78
fix: updating DisappearingScaleBar by kikoso · Pull Request #762 · googlemaps/android-maps-compose · GitHub
Skip to content

Conversation

kikoso
Copy link
Collaborator

@kikoso kikoso commented Sep 15, 2025

This Pull Request modifies the ScaleBar composable to be self-contained and automatically update its text and drawing based on the map's zoom level. It achieves this by introducing a state variable for the horizontal line width and using a LaunchedEffect to listen for camera position changes and update that state.

This change fixes the issue where the DisappearingScaleBar text didn't update dynamically as the user zoomed in or out.

FILE.2025-09-16.11.55.38.mp4

Fixes #759

@kikoso kikoso force-pushed the fix/updating-dissappearing-scale-bar branch from 73f1434 to d87c1f3 Compare September 15, 2025 19:37
@googlemaps-bot
Copy link
Contributor

Code Coverage

There is no coverage information present for the Files changed

@kikoso kikoso marked this pull request as ready for review September 16, 2025 09:55
…tion

This commit enhances the `ScaleBar` composable with performance optimizations,
more robust tests, and comprehensive documentation.

- **Performance**: The `ScaleBar` now uses `remember` with the zoom level as a key,
  and `derivedStateOf` to ensure the scale is only recalculated when the map's
  zoom level changes, not on every pan. This significantly improves efficiency.

- **Tests**: The `ScaleBarTests` are now more reliable. They use a null-safe
  `let` block to prevent potential crashes and calculate the expected scale
  text based on the map's projection for more accurate verification.

- **Documentation**:
    - Added additional KDocs and inline comments to `ScaleBar` and
      `DisappearingScaleBar`, explaining complex calculations and advanced
      Compose concepts.
@dkhawk dkhawk merged commit ca8cf2d into main Sep 16, 2025
10 checks passed
@dkhawk dkhawk deleted the fix/updating-dissappearing-scale-bar branch September 16, 2025 20:04
googlemaps-bot pushed a commit that referenced this pull request Sep 17, 2025
# [6.11.0](v6.10.0...v6.11.0) (2025-09-17)

### Bug Fixes

* tileOverlay in tileOverlayState on TileOverlayNode update ([#755](#755)) ([573e0e2](573e0e2))
* updating DisappearingScaleBar ([#762](#762)) ([ca8cf2d](ca8cf2d))

### Features

* exposing contentDescription on MarkerInfoWindow ([#764](#764)) ([7b55a93](7b55a93))
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 6.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 6.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

1 similar comment
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 6.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DisappearingScaleBar: scale does not update when zooming

3 participants