Skip to content

feat: Maps 3D Compose Wrapper and Samples#39

Merged
dkhawk merged 29 commits intomainfrom
feat/new-compose-wrapper
Apr 21, 2026
Merged

feat: Maps 3D Compose Wrapper and Samples#39
dkhawk merged 29 commits intomainfrom
feat/new-compose-wrapper

Conversation

@dkhawk
Copy link
Copy Markdown
Collaborator

@dkhawk dkhawk commented Apr 14, 2026

This PR introduces a new Jetpack Compose wrapper for the Maps 3D SDK (GoogleMap3D) and implements several sample activities to demonstrate its usage:

  • HelloMapActivity: Basic map display.
  • CameraControlsActivity: Demonstrates camera state hoisting and control.
  • MapInteractionsActivity: Shows how to handle map clicks and interact with the scene.
  • MarkersActivity: Demonstrates adding custom markers (like the alien on Devils Tower) with interactive popovers.

Key features added to the wrapper:

  • Declarative marker support via MarkerConfig.
  • Support for click listeners on markers returning the native Marker instance for popover anchoring.
  • Map mode selection.
  • Steady state callbacks.

All activities are exported in the manifest for direct launching.

@dkhawk dkhawk marked this pull request as draft April 14, 2026 00:04
dkhawk added 8 commits April 14, 2026 11:03
- Added PolylineConfig enhancements (drawsOccludedSegments, onClick).
- Created PolylinesActivity with Sanitas Loop demo (double polyline, hovering).
- Wired click listener to show Toast via rememberCoroutineScope.
- Removed useless MAPS_API_KEY warning from build files.
- Added extruded museum building to PolygonsActivity.kt using a custom extrusion helper.
- Added onClick callback to PolygonConfig in DataModels.kt and handled it in Map3DState.kt.
- Updated PolygonsActivity.kt to use click listeners on the zoo and museum polygons.
- Expanded unit tests in MappersTest.kt to cover default values.
- Cleaned up fully qualified names in DataModels.kt.
- Added missing imports in PolygonsActivity.kt to resolve compilation errors.
…striction crash

- Add MapOptionsActivity to demonstrate map options and camera restrictions.
- Add PopoversActivity to demonstrate popovers.
- Implement toValidCameraRestriction() extension function to sanitize CameraRestriction parameters.
- Provide safe defaults from defined ranges when parameters are null to prevent crashes in the native SDK.
- Ensure min <= max for altitude, heading, and tilt by swapping values if necessary.
- Refactor GoogleMap3D.kt to use the new extension function.
- Update MainActivity and AndroidManifest to include new samples.
- Clean up SampleScreens.kt.
…tecture

- Moved BasicMapSample to its own file for better modularity.

- Implemented ModelsActivity to demonstrate loading 3D models and orchestrating cinematic camera animations.

- Registered ModelsActivity in the manifest and updated MainActivity to launch it.

- Added unit tests in UtilitiesTest.kt for CameraRestriction validation.

- Removed old placeholders from SampleScreens.kt.

- Included pre-existing changes in PolylinesActivity and deletion of properties file.
- Refactor "Basic Map with Marker & Polyline" sample to launch BasicMapActivity instead of using inline state.
- Create BasicMapActivity and register it in the manifest.
- Delete empty SampleScreens.kt file.
- Simplify polyline in PolylinesActivity to fix visual test failure.
- Increase timeout and add delay in Maps3DVisualTest for map interactions.
- Add log in MapInteractionsActivity for debugging clicks.
- Fix ktlint violations and clean up unused imports across the project.
…mentation

- Implement `PopoverConfig` in `DataModels.kt` to support declarative popovers in Compose.
- Add `popovers` parameter and `onMapClick` callback to `GoogleMap3D` composable to enable state-driven popover management and map interaction.
- Implement `syncPopovers` in `Map3DState.kt` to handle the mapping between Compose configurations and native SDK Popover instances.
- Refactor `PopoversActivity` in `maps3d-compose-demo` to demonstrate the declarative API, setting `autoPanEnabled` and `autoCloseEnabled` to false for predictable, state-driven UI behavior.
- Add `README.md` files to both `maps3d-compose` and `maps3d-compose-demo` modules to clarify their purpose as reference implementations.
- Relocate and expand `compose_api_coverage.md` into a comprehensive checklist tracking specific SDK classes and listeners, highlighting unsupported features like `Map3DViewUiController`.
- Update root `README.md` to document the new modules with explicit warnings about their experimental nature.
@dkhawk dkhawk requested a review from kikoso April 14, 2026 21:14
@dkhawk dkhawk marked this pull request as ready for review April 14, 2026 21:14
modifier = modifier,
factory = { context ->
val map3dView = Map3DView(context, options)
map3dView.onCreate(null)
Copy link
Copy Markdown
Collaborator

@kikoso kikoso Apr 15, 2026

Choose a reason for hiding this comment

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

I am thinking if adding this would make sure we can restore the state about reconfiguration changes:

Suggested change
map3dView.onCreate(null)
map3dView.onCreate(LocalSavedStateRegistryOwner.current )

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure we need that since Compose is reapplying the state.


private val client = HttpClient(CIO) {
install(HttpTimeout) {
requestTimeoutMillis = 60000
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.

The nittest of the nits:

Suggested change
requestTimeoutMillis = 60000
requestTimeoutMillis = 60_000

install(HttpTimeout) {
requestTimeoutMillis = 60000
connectTimeoutMillis = 60000
socketTimeoutMillis = 60000
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.

Suggested change
socketTimeoutMillis = 60000
socketTimeoutMillis = 60_000

Comment thread visual-test-examples/ClusteringVisualTest.kt Outdated
dkhawk added 3 commits April 15, 2026 17:16
…40)

* feat: Implement OnCameraChangedListener and add Whiskey Compass demo

- Exposed onCameraChanged callback in GoogleMap3D composable.
- Added WhiskeyCompass composable in demo app.
- Added CameraChangedActivity to demonstrate camera changes with compass, tilt scale, and range scale.
- Updated compose_api_coverage.md.

* docs: Add code reference link for OnCameraChangedListener in coverage doc

* refactor: Move camera changed demo widgets to widgets package

- Moved WhiskeyCompass.kt to widgets package.
- Extracted TiltScale and RangeScale to separate files in widgets package.
- Updated CameraChangedActivity to use widgets from the new package.
* feat: Implement OnCameraChangedListener and add Whiskey Compass demo

- Exposed onCameraChanged callback in GoogleMap3D composable.
- Added WhiskeyCompass composable in demo app.
- Added CameraChangedActivity to demonstrate camera changes with compass, tilt scale, and range scale.
- Updated compose_api_coverage.md.

* docs: Add code reference link for OnCameraChangedListener in coverage doc

* refactor: Move camera changed demo widgets to widgets package

- Moved WhiskeyCompass.kt to widgets package.
- Extracted TiltScale and RangeScale to separate files in widgets package.
- Updated CameraChangedActivity to use widgets from the new package.

* feat: Implement PinConfiguration support and add visual test

* docs: Update API coverage for PinConfiguration

* docs: Clean up compose coverage file

* docs: Remove supported items from Not Yet Exposed list

* docs: Remove PinView from coverage checklist

* feat: Implement OnPlaceClickListener support and add visual test

* docs: Remove unsupported APIs from coverage checklist
Comment thread maps3d-compose-demo/build.gradle.kts Outdated
dkhawk added 2 commits April 20, 2026 16:25
…tation test

- Refactor `GoogleMap3D` and `ThreeDMap` to avoid calling `getMap3DViewAsync` on every recomposition by moving it to the `factory` block of `AndroidView`.
- Use `rememberUpdatedState` in `GoogleMap3D` for callbacks to prevent stale captures.
- Add `verifyRotationMaintainsMap` visual test to verify map rendering after device rotation.
- Remove reference files in `visual-test-examples` directory as requested.
- Move Spotless plugin to versions catalog and upgrade several dependencies (Places to 5.2.0, Spotless to 8.4.0, Ktor to 3.4.2, etc.).
- Clean up `truth` library usage across modules, favoring `google-truth`.
- Fix Spotless formatting warnings in `CameraChangedActivity.kt` and `WhiskeyCompass.kt`.
- Improve formatting of the `WhiskeyCompass` composable.
- Migrated Spotless plugin to use version catalog alias in build files.
- Increased the rendering margin in `WhiskeyCompass` to prevent visual pop-in.
@dkhawk dkhawk enabled auto-merge (squash) April 20, 2026 22:46
Copy link
Copy Markdown
Collaborator

@kikoso kikoso left a comment

Choose a reason for hiding this comment

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

LGTM!

@dkhawk dkhawk merged commit 16a492a into main Apr 21, 2026
3 of 6 checks passed
@dkhawk dkhawk deleted the feat/new-compose-wrapper branch April 21, 2026 15:09
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.

2 participants