-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Maps 3D Compose Wrapper and Samples #39
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
Open
dkhawk
wants to merge
25
commits into
main
Choose a base branch
from
feat/new-compose-wrapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6dd161d
feat: Implement Maps 3D Compose wrapper, sample catalog, and visual t…
dkhawk 403066e
feat: Implement Hello Map sample as a separate activity centered on F…
dkhawk 2a2fc84
feat: Switch Hello Map location to Delicate Arch and fix visual test
dkhawk d6560b0
feat: Calibrate camera pose for Delicate Arch in HelloMapActivity
dkhawk 3830272
chore: Add visual test examples and gradle daemon properties
dkhawk 80b110f
feat: Add Camera Controls activity and calibrate for Seattle
dkhawk 11e1d5e
feat: Add Map Interactions sample calibrated for Denver Capitol
dkhawk 3cf36b8
refactor: Reorder parameters in GoogleMap3D to follow Compose convention
dkhawk f5c9160
test: Use conventional UiAutomator testing for Map Interactions fallback
dkhawk 8a1c759
test: Verify Markers sample with visual test
dkhawk 365d86f
test: Verify Markers sample with popover and extruded marker
dkhawk c527626
feat: Export all sample activities in manifest
dkhawk 4bf0664
feat: Remove unnecessary Back buttons from sample activities
dkhawk 1c06045
feat: Support onClick callback in MarkerConfig and use it in MarkersA…
dkhawk 29699c1
refactor: Clean up fully qualified class names in DataModels and Mark…
dkhawk 667fb6e
feat: Migrate Sanitas Loop polyline to maps3d-compose
dkhawk 0c91270
fix: Remove extra brace in build.gradle.kts files
dkhawk e570288
build: Add installAndLaunch task to maps3d-compose-demo
dkhawk 1f35ae9
feat: Add extruded museum and click support to Polygons example
dkhawk 0962524
feat(compose): Add Map Options and Popovers samples, and fix CameraRe…
dkhawk 7c9054d
feat(maps3d-compose): Implement Models sample and refactor demo archi…
dkhawk 82305b8
Refactor Basic Map sample to launch as a separate activity
dkhawk b7a499d
feat(maps3d-compose): Add declarative Popover support and update docu…
dkhawk 8b33e37
feat: Implement OnCameraChangedListener and add Whiskey Compass demo …
dkhawk 82e618b
feat: Implement PinConfiguration support and add visual test (#41)
dkhawk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Maps 3D Compose Demo | ||
|
|
||
| This module is a sample application that demonstrates how to use the `maps3d-compose` wrapper library. | ||
|
|
||
| > [!WARNING] | ||
| > **Status**: This application serves as a **reference implementation** for using the experimental Compose wrapper. It is a WIP experiment. | ||
|
|
||
| ## What's Inside | ||
|
|
||
| You can find several sample activities demonstrating different features of the 3D Map in Compose: | ||
| - **Basic Map**: A simple map with camera controls. | ||
| - **Map Options**: Demonstrates changing map modes (Satellite/Hybrid) and applying camera restrictions. | ||
| - **Models**: Shows how to add and interact with 3D models (glTF) on the map, including click listeners. | ||
| - **Popovers**: Demonstrates the declarative Popover API, rendering Compose content inside native map popovers. | ||
|
|
||
| ## How to Run | ||
|
|
||
| You can install and run this demo on a connected device or emulator using: | ||
| ```bash | ||
| ./gradlew :maps3d-compose-demo:installDebug | ||
| ``` | ||
| Then launch any of the activities via the launcher or ADB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.android.application) | ||
| alias(libs.plugins.kotlin.android) | ||
| alias(libs.plugins.kotlin.compose) | ||
| alias(libs.plugins.secrets.gradle.plugin) | ||
| id("com.diffplug.spotless") version "6.25.0" | ||
| } | ||
|
|
||
| configure<com.diffplug.gradle.spotless.SpotlessExtension> { | ||
| kotlin { | ||
| target("**/*.kt") | ||
| ktlint().editorConfigOverride(mapOf("indent_size" to "4", "ktlint_function_naming_ignore_when_annotated_with" to "Composable")) | ||
| trimTrailingWhitespace() | ||
| endWithNewline() | ||
| } | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.example.maps3dcomposedemo" | ||
| compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.example.maps3dcomposedemo" | ||
| minSdk = libs.versions.minSdk.get().toInt() | ||
| targetSdk = libs.versions.targetSdk.get().toInt() | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
|
|
||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| vectorDrawables { | ||
| useSupportLibrary = true | ||
| } | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| } | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_11 | ||
| targetCompatibility = JavaVersion.VERSION_11 | ||
| } | ||
| kotlin { | ||
| compilerOptions { | ||
| jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11) | ||
| } | ||
| } | ||
| buildFeatures { | ||
| compose = true | ||
| buildConfig = true | ||
| } | ||
| packaging { | ||
| resources { | ||
| excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(project(":maps3d-compose")) | ||
|
|
||
| implementation(libs.androidx.core.ktx) | ||
| implementation(libs.androidx.lifecycle.runtime.ktx) | ||
| implementation(libs.androidx.activity.compose) | ||
|
|
||
| implementation(platform(libs.androidx.compose.bom)) | ||
| implementation(libs.androidx.ui) | ||
| implementation(libs.androidx.ui.graphics) | ||
| implementation(libs.androidx.ui.tooling.preview) | ||
| implementation(libs.androidx.material3) | ||
|
|
||
| // Maps 3D SDK | ||
| implementation(libs.play.services.maps3d) | ||
|
|
||
| testImplementation(libs.junit) | ||
| androidTestImplementation(libs.androidx.junit) | ||
| androidTestImplementation(libs.androidx.espresso.core) | ||
| androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
| androidTestImplementation(libs.androidx.ui.test.junit4) | ||
| androidTestImplementation(libs.androidx.uiautomator) | ||
| androidTestImplementation(libs.kotlinx.serialization.json) | ||
| androidTestImplementation(project(":visual-testing")) | ||
| debugImplementation(libs.androidx.ui.tooling) | ||
| debugImplementation(libs.androidx.ui.test.manifest) | ||
| } | ||
|
|
||
| secrets { | ||
| propertiesFileName = "secrets.properties" | ||
| } | ||
|
|
||
| tasks.register<Exec>("installAndLaunch") { | ||
| description = "Installs and launches the demo app." | ||
| group = "install" | ||
| dependsOn("installDebug") | ||
| commandLine("adb", "shell", "am", "start", "-n", "com.example.maps3dcomposedemo/.MainActivity") | ||
| } | ||
70 changes: 70 additions & 0 deletions
70
maps3d-compose-demo/src/androidTest/java/com/example/maps3dcomposedemo/BaseVisualTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.example.maps3dcomposedemo | ||
|
|
||
| import android.app.Instrumentation | ||
| import android.content.Context | ||
| import android.graphics.Bitmap | ||
| import android.graphics.BitmapFactory | ||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import androidx.test.uiautomator.By | ||
| import androidx.test.uiautomator.UiDevice | ||
| import androidx.test.uiautomator.Until | ||
| import com.google.maps.android.visualtesting.GeminiVisualTestHelper | ||
| import org.junit.Assert.assertTrue | ||
| import java.io.File | ||
|
|
||
| abstract class BaseVisualTest { | ||
|
|
||
| protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() | ||
| protected val uiDevice = UiDevice.getInstance(instrumentation) | ||
| protected val context: Context = instrumentation.targetContext | ||
| protected val helper = GeminiVisualTestHelper() | ||
|
|
||
| protected val geminiApiKey: String by lazy { | ||
| val key = BuildConfig.GEMINI_API_KEY | ||
| assertTrue( | ||
| "GEMINI_API_KEY is not set in secrets.properties. Please add GEMINI_API_KEY=YOUR_API_KEY to your secrets.properties file.", | ||
| key != "YOUR_GEMINI_API_KEY", | ||
| ) | ||
| key | ||
| } | ||
|
|
||
| protected fun captureScreenshot(filename: String = "screenshot_${System.currentTimeMillis()}.png"): Bitmap { | ||
| val screenshotFile = File(context.getExternalFilesDir(null), filename) | ||
| val screenshotTaken = uiDevice.takeScreenshot(screenshotFile) | ||
| assertTrue("Failed to take screenshot: $filename", screenshotTaken) | ||
|
|
||
| val bitmap = BitmapFactory.decodeFile(screenshotFile.absolutePath) | ||
| assertTrue("Failed to decode screenshot file: $filename", bitmap != null) | ||
|
|
||
| println("Screenshot saved to device: ${screenshotFile.absolutePath}") | ||
| println("To pull: adb pull ${screenshotFile.absolutePath}") | ||
|
|
||
| return bitmap | ||
| } | ||
|
|
||
| /** | ||
| * Waits for the map to render. | ||
| * Since MapView content (tiles, markers) is rendered on a GL surface and not exposed as | ||
| * accessibility nodes, we cannot rely on UiAutomator looking for text/markers. | ||
| * We use a stable delay to ensure rendering is complete. | ||
| */ | ||
| protected fun waitForMapRendering(timeoutSeconds: Long = 30) { | ||
| val found = uiDevice.wait(Until.hasObject(By.desc("MapSteady")), timeoutSeconds * 1000) | ||
| assertTrue("Map did not become steady within $timeoutSeconds seconds", found) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could this be moved to the catalog?