Skip to content

fix(maps-compose): apply initial camera during map creation - #1027

Merged
kikoso merged 4 commits into
googlemaps:mainfrom
RotBolt:fix/491-initial-camera-options
Nov 25, 2026
Merged

kikoso merged 4 commits into
googlemaps:mainfrom
RotBolt:fix/491-initial-camera-options

Conversation

@RotBolt

@RotBolt RotBolt commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #491.

Summary

  • Apply CameraPositionState.position to GoogleMapOptions before map creation, including when googleMapOptionsFactory supplies a camera. This matches the camera applied when the map attaches and avoids a startup jump.
  • Apply this in the shared delegate-backed implementation so both GoogleMap overloads use the same precedence; document that precedence on both overloads.
  • Add instrumentation coverage for the initial options and loaded camera, plus JVM assertions on the options passed to the regular and delegate factories.
  • Rebase onto the latest main after feat: support custom MapView delegates and add Navigation SDK sample app #1061 and preserve the existing Robolectric camera-binding coverage rather than duplicating it.

Validation

After the latest rebase and review fixes:

  • :maps-compose:testDebugUnitTest — passed (44 tests, no failures or skips)
  • :maps-app:compileDebugAndroidTestKotlin — passed
  • lint — passed
  • apiCheck — passed
  • git diff --check — passed

Instrumentation tests and Baseline Profile regeneration were not run locally after this rebase because no Android device or emulator is connected.

  • Opened issue before implementation
  • Tests added
  • Lint passed
  • Coverage report reviewed

@google-cla

google-cla Bot commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@RotBolt
RotBolt marked this pull request as ready for review October 6, 2026 08:00
@RotBolt
RotBolt marked this pull request as draft October 6, 2026 08:03
@RotBolt
RotBolt marked this pull request as ready for review October 6, 2026 08:15
@RotBolt

RotBolt commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@dkhawk I've merged the latest main and resolved the conflict with #1029. The Lite-mode color-scheme guard is preserved, and the initial camera is applied through baseOptions.

Validation after the merge:

  • Compilation and lint passed.
  • Both initial-camera tests and all four Lite-mode options tests passed on a Motorola Edge 50 Neo running Android 16.
  • :maps-compose:testDebugUnitTest completed with NO-SOURCE.

Could you review this PR, particularly the initial-camera precedence? I've also signed the CLA.

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution, @RotBolt ! Can you take a look at the comments? The branch has conflicts with main again after the latest changes in GoogleMap.kt, could you rebase it?

@RotBolt
RotBolt force-pushed the fix/491-initial-camera-options branch from a418cf9 to b69c2bd Compare October 29, 2026 15:16
@RotBolt
RotBolt force-pushed the fix/491-initial-camera-options branch from b69c2bd to 76d9222 Compare November 16, 2026 17:38
@RotBolt

RotBolt commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@kikoso Could you review this again? I've rebased the branch onto the latest main and pushed it as 76d9222f. GitHub now reports no merge conflicts.

The branch includes the precedence change you suggested: CameraPositionState.position always supplies the initial options camera, matching CameraPositionState.setMap. The options tests have been updated, and there's also a unit test for camera application on binding and an instrumentation test for the loaded camera position. The rebase preserves the current Lite-mode color-scheme handling and moves the instrumentation tests with main into compose/demo.

Validation after the rebase:

  • :maps-compose:testDebugUnitTest — passed (23 tests, no failures or skips)
  • :maps-app:compileDebugAndroidTestKotlin — passed
  • lint — passed
  • git diff --check — passed

I couldn't run instrumentation tests locally because no Android device or emulator is connected.

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks for the contribution and for your patience, @RotBolt . It needs a rebase now that #1061 has landed, since that one moved the GoogleMap overloads around.

@RotBolt
RotBolt force-pushed the fix/491-initial-camera-options branch from 76d9222 to 5d96a9a Compare November 24, 2026 12:44
@RotBolt

RotBolt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@kikoso Thanks for the approval! I rebased onto the latest main after #1061 and pushed 5d96a9a8. The initial camera is applied in the shared delegate-backed implementation, and GitHub reports no merge conflicts.

I also addressed and replied to all four review threads: camera assertions now run outside the main-thread callback, the redundant binding test is covered by main’s existing test, and JVM assertions now check the options passed to both map factories.

Could you take another look at the rebased changes and confirm approval?

@kikoso
kikoso enabled auto-merge (squash) November 25, 2026 04:39
@kikoso
kikoso merged commit d657239 into googlemaps:main Nov 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map initialization with desired configuration is delayed

3 participants