-
Notifications
You must be signed in to change notification settings - Fork 5
feat(codelab): introduce aloha explorer 3d maps starter and solution #36
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
1
commit into
main
Choose a base branch
from
feat/adds-codelab
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,16 @@ | ||
| *.iml | ||
| .gradle | ||
| /local.properties | ||
| /.idea/caches | ||
| /.idea/libraries | ||
| /.idea/modules.xml | ||
| /.idea/workspace.xml | ||
| /.idea/navEditor.xml | ||
| /.idea/assetWizardSettings.xml | ||
| .DS_Store | ||
| /build | ||
| /captures | ||
| .externalNativeBuild | ||
| .cxx | ||
| local.properties | ||
| /secrets.properties |
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 @@ | ||
| /build |
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,93 @@ | ||
| plugins { | ||
| alias(libs.plugins.android.application) | ||
| alias(libs.plugins.kotlin.android) | ||
| alias(libs.plugins.kotlin.compose) | ||
| alias(libs.plugins.secrets.gradle.plugin) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.example.alohaexplorer" | ||
| compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
|
||
| buildFeatures { | ||
| viewBinding = true | ||
| compose = true | ||
| buildConfig = true | ||
| } | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.example.alohaexplorer" | ||
| minSdk = libs.versions.minSdk.get().toInt() | ||
| targetSdk = libs.versions.targetSdk.get().toInt() | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
|
|
||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| } | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
| buildFeatures { | ||
| compose = true | ||
| buildConfig = true | ||
| } | ||
| } | ||
|
|
||
| kotlin { | ||
| compilerOptions { | ||
| jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.androidx.activity) | ||
| implementation(libs.androidx.activity.compose) | ||
| implementation(libs.androidx.appcompat) | ||
| implementation(libs.androidx.constraintlayout) | ||
| implementation(libs.androidx.core.ktx) | ||
| implementation(libs.androidx.lifecycle.runtime.ktx) | ||
| implementation(libs.androidx.material3) | ||
| implementation(libs.androidx.ui) | ||
| implementation(libs.androidx.ui.graphics) | ||
| implementation(libs.androidx.ui.tooling.preview) | ||
| implementation(libs.material) | ||
| implementation(platform(libs.androidx.compose.bom)) | ||
|
|
||
| debugImplementation(libs.androidx.ui.tooling) | ||
|
|
||
| testImplementation(libs.junit) | ||
|
|
||
| androidTestImplementation(libs.androidx.junit) | ||
| androidTestImplementation(libs.androidx.espresso.core) | ||
|
|
||
| implementation(libs.play.services.maps3d) | ||
| } | ||
|
|
||
| secrets { | ||
| // Optionally specify a different file name containing your secrets. | ||
| // The plugin defaults to "local.properties" | ||
| propertiesFileName = "secrets.properties" | ||
|
|
||
| // A properties file containing default secret values. This file can be | ||
| // checked in version control. | ||
| defaultPropertiesFileName = "local.defaults.properties" | ||
| } | ||
|
|
||
| tasks.register<Exec>("launchDebug") { | ||
| dependsOn("installDebug") | ||
| commandLine("adb", "shell", "am", "start", "-n", "com.example.alohaexplorer/.MainActivity") | ||
| doLast { | ||
| println("Launched com.example.alohaexplorer/.MainActivity") | ||
| } | ||
| } | ||
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,21 @@ | ||
| # Add project specific ProGuard rules here. | ||
| # You can control the set of applied configuration files using the | ||
| # proguardFiles setting in build.gradle. | ||
| # | ||
| # For more details, see | ||
| # http://developer.android.com/guide/developing/tools/proguard.html | ||
|
|
||
| # If your project uses WebView with JS, uncomment the following | ||
| # and specify the fully qualified class name to the JavaScript interface | ||
| # class: | ||
| #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| # public *; | ||
| #} | ||
|
|
||
| # Uncomment this to preserve the line number information for | ||
| # debugging stack traces. | ||
| #-keepattributes SourceFile,LineNumberTable | ||
|
|
||
| # If you keep the line number information, uncomment this to | ||
| # hide the original source file name. | ||
| #-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...ab/solution/app/src/androidTest/java/com/example/alohaexplorer/ExampleInstrumentedTest.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,24 @@ | ||
| package com.example.alohaexplorer | ||
|
|
||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
|
||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
|
|
||
| import org.junit.Assert.* | ||
|
|
||
| /** | ||
| * Instrumented test, which will execute on an Android device. | ||
| * | ||
| * See [testing documentation](http://d.android.com/tools/testing). | ||
| */ | ||
| @RunWith(AndroidJUnit4::class) | ||
| class ExampleInstrumentedTest { | ||
| @Test | ||
| fun useAppContext() { | ||
| // Context of the app under test. | ||
| val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
| assertEquals("com.example.alohaexplorer", appContext.packageName) | ||
| } | ||
| } |
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,36 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools"> | ||
|
|
||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
| <application | ||
| android:allowBackup="true" | ||
| android:dataExtractionRules="@xml/data_extraction_rules" | ||
| android:fullBackupContent="@xml/backup_rules" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@style/Theme.AlohaExplorer"> | ||
|
|
||
| <meta-data | ||
| android:name="com.google.android.geo.maps3d.API_KEY" | ||
| android:value="${MAPS3D_API_KEY}" | ||
| /> | ||
|
|
||
| <activity | ||
| android:name=".MainActivity" | ||
| android:exported="true"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
|
|
||
| <activity | ||
| android:name=".Map3DComposeActivity" | ||
| android:exported="true" | ||
| android:label="Aloha Compose" /> | ||
| </application> | ||
|
|
||
| </manifest> |
107 changes: 107 additions & 0 deletions
107
codelab/solution/app/src/main/java/com/example/alohaexplorer/HonoluluData.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,107 @@ | ||
| package com.example.alohaexplorer | ||
|
|
||
| import com.google.android.gms.maps3d.model.camera | ||
| import com.google.android.gms.maps3d.model.latLngAltitude | ||
|
|
||
| // Step 1: Honolulu | ||
| val HONOLULU = latLngAltitude { | ||
| latitude = 21.3069 | ||
| longitude = -157.8583 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| // Step 2: Iolani Palace | ||
| val IOLANI_PALACE = latLngAltitude { | ||
| latitude = 21.306740 | ||
| longitude = -157.858803 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| // Step 6: Waikiki Beach | ||
| val WAIKIKI = latLngAltitude { | ||
| latitude = 21.2766 | ||
| longitude = -157.8286 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| val DIAMOND_HEAD = latLngAltitude { | ||
| latitude = 21.26194 | ||
| longitude = -157.80556 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| val KOKO_HEAD = latLngAltitude { | ||
| latitude = 21.270856 | ||
| longitude = -157.694442 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| val PEARL_HARBOR = latLngAltitude { | ||
| latitude = 21.31861 | ||
| longitude = -157.92250 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| val MOUNT_KAALA = latLngAltitude { | ||
| latitude = 21.50694 | ||
| longitude = -158.14278 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| val LANIKAI_BEACH = latLngAltitude { | ||
| latitude = 21.39309 | ||
| longitude = -157.71546 | ||
| altitude = 0.0 | ||
| } | ||
|
|
||
| // Models must be loaded from a URL. Here we use Cloud Storage. | ||
| const val BALLOON_MODEL_URL = "https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/balloon-pin-BlXF32yD.glb" | ||
| const val BALLOON_SCALE = 5.0 | ||
|
|
||
| // Step 5: Iolani Palace Geometry (Lat, Lng pairs) | ||
| val IOLANI_PALACE_GEO = listOf( | ||
| 21.307180365, -157.858769898, | ||
| 21.306765552, -157.858390366, | ||
| 21.306476932, -157.858755146, | ||
| 21.306892995, -157.859134679, | ||
| ) | ||
|
|
||
| val POLYGON_CAMERA = camera { | ||
| center = latLngAltitude { | ||
| latitude = 21.307051 | ||
| longitude = -157.858546 | ||
| altitude = 7.1 | ||
| } | ||
| heading = 78.0 | ||
| tilt = 53.0 | ||
| range = 644.0 | ||
| } | ||
|
|
||
| val MARKER_CAMERA = camera { | ||
| center = latLngAltitude { | ||
| latitude = 21.306648 | ||
| longitude = -157.859336 | ||
| altitude = 26.8 | ||
| } | ||
| tilt = 68.0 | ||
| range = 1024.0 | ||
| heading = 61.0 | ||
| } | ||
|
|
||
| val CUSTOM_MARKER_CAMERA = camera { | ||
| this.center = latLngAltitude { | ||
| this.latitude = 21.306370 | ||
| this.longitude = -157.855474 | ||
| this.altitude = 6.6 | ||
| } | ||
| this.heading = 39.0 | ||
| this.tilt = 68.0 | ||
| this.range = 1399.0 | ||
| } | ||
|
|
||
| val BALLOON_CAMERA = camera { | ||
| center = WAIKIKI | ||
| tilt = 60.0 | ||
| range = 1000.0 | ||
| heading = 0.0 | ||
| } |
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.
Duplicate
buildFeaturesblock, the first is on line 12. Kotlin DSL applies both to the same extension so it compiles and behaves identically, but it hides the one real difference between them: line 13 setsviewBinding = true, and this second block does not.That
viewBinding = truealso looks unused. BothMainActivity.ktfiles reach for views throughfindViewById(solution line 92, plus lines 517-616), and nothing in either module imports a generated*Bindingtype. The starter'sbuild.gradle.ktsdoes not enable it at all, so the two projects differ in a way the codelab never explains.Suggest merging into the single block below and dropping
viewBindingunless a later step is meant to use it: