Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maps3DSamples/ApiDemos/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ dependencies {

api(libs.play.services.base) // "com.google.android.gms:play-services-base:18.10.0"
api(libs.play.services.maps3d) // "com.google.android.gms:play-services-maps3d:0.2.2"
api(libs.maps.utils.ktx)
api(libs.android.maps.utils)
}

jacoco {
Expand Down
10 changes: 8 additions & 2 deletions Maps3DSamples/ComposeDemos/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ plugins {
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"))
ktlint().editorConfigOverride(
mapOf(
"indent_size" to "4",
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_max-line-length" to "disabled",
),
)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down Expand Up @@ -101,7 +107,7 @@ dependencies {
implementation(libs.androidx.fragment.ktx)

// Maps Utils
implementation(libs.maps.utils.ktx)
implementation(libs.android.maps.utils)

// Material Icons Extended
implementation(libs.androidx.material.icons.extended)
Expand Down
2 changes: 1 addition & 1 deletion Maps3DSamples/advanced/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ dependencies {
testImplementation(libs.google.truth)

// Google Maps Utils for the polyline decoder
implementation(libs.maps.utils.ktx)
implementation(libs.android.maps.utils)

implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package com.example.advancedmaps3dsamples.scenarios

import com.example.advancedmaps3dsamples.R
import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.ktx.utils.latLngListEncode
import com.google.maps.android.latLngListEncode

const val PLANE_URL = "https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/Airplane.glb"
const val PLANE_SCALE = 0.05
Expand Down
2 changes: 1 addition & 1 deletion PlacesUIKit3D/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ dependencies {
implementation(libs.play.services.maps3d) // The core SDK for embedding 3D Google Maps.
implementation(libs.places) // The SDK for the Places UI Kit (PlaceDetails fragments).
implementation(libs.places.compose) // Official Places Compose autocomplete UI kit.
implementation(libs.maps.utils.ktx) // Google Maps Utils for polyline decoding and other utilities.
implementation(libs.android.maps.utils) // Google Maps Utils for polyline decoding and other utilities.

// --- Dependency Injection ---
// Hilt is used for managing dependencies and object lifecycles.
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kotlinxSerialization = "1.11.0"
ktor = "3.5.2"
hilt = "2.60.1"
ksp = "2.3.6"
mapsUtilsKtx = "6.3.0"
mapsUtils = "6.0.0-rc04"
androidx-core-ktx = "1.8.9"
androidxArchCoreTesting = "2.2.0"
kotlinxCoroutines = "1.8.0"
Expand Down Expand Up @@ -83,7 +83,8 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
maps-utils-ktx = { module = "com.google.maps.android:maps-utils-ktx", version.ref = "mapsUtilsKtx" }
android-maps-utils = { module = "com.google.maps.android:android-maps-utils", version.ref = "mapsUtils" }
android-maps-utils-core = { module = "com.google.maps.android:android-maps-utils-core", version.ref = "mapsUtils" }
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }

[plugins]
Expand Down
8 changes: 7 additions & 1 deletion maps3d-compose-demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ plugins {
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"))
ktlint().editorConfigOverride(
mapOf(
"indent_size" to "4",
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_max-line-length" to "disabled",
),
)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ abstract class BaseVisualTest {
key
}

protected fun captureScreenshot(filename: String = "screenshot_${System.currentTimeMillis()}.png"): Bitmap {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ class Maps3DVisualTest : BaseVisualTest() {

// Parse JSON and click
try {
val jsonStr = geminiResponse?.substringAfter("{")?.substringBeforeLast("}")?.let { "{$it}" } ?: ""
val jsonStr =
geminiResponse?.substringAfter("{")?.substringBeforeLast("}")?.let { "{$it}" }
?: ""
val json = org.json.JSONObject(jsonStr)
val x = json.getDouble("x")
val y = json.getDouble("y")
Expand All @@ -418,7 +420,9 @@ class Maps3DVisualTest : BaseVisualTest() {

uiDevice.click(clickX, clickY)
} catch (e: Exception) {
org.junit.Assert.fail("Failed to parse coordinates from Gemini response: $geminiResponse. Error: ${e.message}")
org.junit.Assert.fail(
"Failed to parse coordinates from Gemini response: $geminiResponse. Error: ${e.message}",
)
}

// Wait for UI to update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ fun MapInteractionsScreen() {
map3dInstance = instance
// Set up click listener directly on the instance
instance.setMap3DClickListener { location, placeId ->
Log.d("MapInteractionsActivity", "Map clicked at ${location.latitude}, ${location.longitude}")
Log.d(
"MapInteractionsActivity",
"Map clicked at ${location.latitude}, ${location.longitude}",
)
clickedInfo = if (placeId != null) {
"Clicked Place ID: $placeId\nAt: ${location.latitude}, ${location.longitude}"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ fun TiltScale(tilt: Float, modifier: Modifier = Modifier) {
)

if (isMajor) {
val measuredText = textMeasurer.measure(i.toString(), style = TextStyle(color = onPrimaryColor, fontSize = 12.sp))
val measuredText = textMeasurer.measure(
i.toString(),
style = TextStyle(color = onPrimaryColor, fontSize = 12.sp),
)
drawText(
textLayoutResult = measuredText,
topLeft = Offset(centerLineX + 20f, yPos - measuredText.size.height / 2f),
topLeft = Offset(
centerLineX + 20f,
yPos - measuredText.size.height / 2f,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ fun WhiskeyCompass(

showDegreeLabels: Boolean = true,
degreeLabelInterval: Int = 15,
degreeLabelTextStyle: TextStyle = MaterialTheme.typography.labelSmall.copy(textAlign = TextAlign.Center),
degreeLabelTextStyle: TextStyle = MaterialTheme.typography.labelSmall.copy(
textAlign = TextAlign.Center,
),
degreeLabelVerticalOffset: Dp = 4.dp,

showCardinalLabels: Boolean = true,
Expand Down Expand Up @@ -142,7 +144,9 @@ fun WhiskeyCompass(
val absoluteDegree = repetitionBaseDegree + degreeInRepetition
val xPos = absoluteDegree * pixelsPerDegree

if (xPos < -xOffset + canvasWidth + canvasWidth && xPos > -xOffset - canvasWidth) {
if (xPos < -xOffset + canvasWidth + canvasWidth &&
xPos > -xOffset - canvasWidth
) {
val isMajorTickEquivalent = degreeInRepetition % 10 == 0
val isMinorTickEquivalent =
degreeInRepetition % 5 == 0 && !isMajorTickEquivalent
Expand All @@ -167,7 +171,9 @@ fun WhiskeyCompass(
textLayoutResult = measuredText,
topLeft = Offset(
x = xPos - measuredText.size.width / 2f,
y = tickTopY - measuredText.size.height - cardinalLabelVerticalOffsetPx,
y =
tickTopY - measuredText.size.height -
cardinalLabelVerticalOffsetPx,
),
)
}
Expand Down Expand Up @@ -272,7 +278,9 @@ private fun FlatWhiskeyCompassPreview() {
lubberLineColor = Color(0xFFFFD600),
pixelsPerDegree = 12f,
degreeLabelInterval = 10,
degreeLabelTextStyle = MaterialTheme.typography.bodySmall.copy(color = Color(0xFF81D4FA)),
degreeLabelTextStyle = MaterialTheme.typography.bodySmall.copy(
color = Color(0xFF81D4FA),
),
cardinalLabelTextStyle = MaterialTheme.typography.labelLarge.copy(
color = Color.White,
fontWeight = FontWeight.Bold,
Expand Down
10 changes: 8 additions & 2 deletions maps3d-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ plugins {
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"))
ktlint().editorConfigOverride(
mapOf(
"indent_size" to "4",
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_max-line-length" to "disabled",
),
)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down Expand Up @@ -66,7 +72,7 @@ dependencies {

// Maps 3D SDK
implementation(libs.play.services.maps3d)
implementation(libs.maps.utils.ktx)
implementation(libs.android.maps.utils)

testImplementation(libs.junit)
testImplementation(libs.robolectric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fun GoogleMap3D(
minTilt = 0.0,
maxTilt = 90.0,
bounds = null,
mapMode = Map3DMode.SATELLITE, // using the class from com.google.android.gms.maps3d.model.Map3DMode
mapMode = Map3DMode.SATELLITE,
mapId = null,
minAltitude = 0.0,
maxAltitude = 1000000.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ fun getUnitsConverter(countryCode: String?): UnitsConverter {

/** Class to render measurements in imperial units. */
object ImperialUnitsConverter : UnitsConverter() {
override fun toDistanceUnits(meters: Meters): ValueWithUnitsTemplate = if (meters < 0.25.miles) {
override fun toDistanceUnits(meters: Meters): ValueWithUnitsTemplate = if (meters <
0.25.miles
) {
ValueWithUnitsTemplate(meters.toFeet, R.string.in_feet)
} else {
ValueWithUnitsTemplate(meters.toMiles, R.string.in_miles)
Expand All @@ -148,7 +150,9 @@ object ImperialUnitsConverter : UnitsConverter() {

/** Class to render measurements in metric units. */
object MetricUnitsConverter : UnitsConverter() {
override fun toDistanceUnits(meters: Meters): ValueWithUnitsTemplate = if (meters < 1000.meters) {
override fun toDistanceUnits(meters: Meters): ValueWithUnitsTemplate = if (meters <
1000.meters
) {
ValueWithUnitsTemplate(meters.toMeters, R.string.in_meters)
} else {
ValueWithUnitsTemplate(meters.toKilometers, R.string.in_kilometers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ fun FlyAroundOptions.copy(
}
}

fun FlyToOptions.copy(
endCamera: Camera? = null,
durationInMillis: Long? = null,
): FlyToOptions {
fun FlyToOptions.copy(endCamera: Camera? = null, durationInMillis: Long? = null): FlyToOptions {
val objectToCopy = this

return flyToOptions {
Expand Down
8 changes: 1 addition & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ pluginManagement {
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
val useLocalMaven = providers.gradleProperty("use_local_maven")
.getOrElse("false")
.toBoolean()

if (useLocalMaven) {
mavenLocal()
}
mavenLocal()
google()
mavenCentral()
}
Expand Down
8 changes: 7 additions & 1 deletion snippets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ subprojects {
}
kotlin {
target("**/*.kt")
ktlint().editorConfigOverride(mapOf("indent_size" to "4", "ktlint_function_naming_ignore_when_annotated_with" to "Composable"))
ktlint().editorConfigOverride(
mapOf(
"indent_size" to "4",
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_max-line-length" to "disabled",
),
)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class MapActivity : AppCompatActivity() {
val groupTitle = intent.getStringExtra("group_title")
val snippetTitle = intent.getStringExtra(EXTRA_SNIPPET_TITLE)
val snippetList = SnippetRegistry.getSnippetGroups().flatMap { it.items }
var currentIndex = snippetList.indexOfFirst { it.title == snippetTitle && (groupTitle == null || it.groupTitle == groupTitle) }
var currentIndex = snippetList.indexOfFirst {
it.title == snippetTitle &&
(groupTitle == null || it.groupTitle == groupTitle)
}

findViewById<MaterialButton>(R.id.snapshot_button).apply {
setOnClickListener {
Expand Down Expand Up @@ -187,7 +190,10 @@ class MapActivity : AppCompatActivity() {
if (snippetTitle == null) return
val key = if (groupTitle != null) "$groupTitle - $snippetTitle" else snippetTitle
val snippet = SnippetRegistry.snippets[key]
?: SnippetRegistry.getSnippetGroups().flatMap { it.items }.find { it.title == snippetTitle }
?: SnippetRegistry.getSnippetGroups().flatMap { it.items }.find {
it.title ==
snippetTitle
}
?: return
if (!::googleMap3D.isInitialized) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ object SnippetRegistry {
// Most snippet methods take no args because they use initialized class fields
if (method.parameterCount == 0) {
method.invoke(instance)
} else if (method.parameterCount == 1 && method.parameterTypes[0] == Context::class.java) {
} else if (method.parameterCount == 1 &&
method.parameterTypes[0] == Context::class.java
) {
method.invoke(instance, context)
} else {
// Fallback or log error
Expand All @@ -132,14 +134,29 @@ object SnippetRegistry {
return groups
}

private fun createInstance(clazz: Class<*>, context: Context, map: TrackedMap3D, scope: CoroutineScope): Any = try {
clazz.getConstructor(Context::class.java, TrackedMap3D::class.java, CoroutineScope::class.java).newInstance(context, map, scope)
private fun createInstance(
clazz: Class<*>,
context: Context,
map: TrackedMap3D,
scope: CoroutineScope,
): Any = try {
clazz.getConstructor(
Context::class.java,
TrackedMap3D::class.java,
CoroutineScope::class.java,
).newInstance(context, map, scope)
} catch (e: Exception) {
try {
clazz.getConstructor(TrackedMap3D::class.java, CoroutineScope::class.java).newInstance(map, scope)
clazz.getConstructor(
TrackedMap3D::class.java,
CoroutineScope::class.java,
).newInstance(map, scope)
} catch (e: Exception) {
try {
clazz.getConstructor(Context::class.java, TrackedMap3D::class.java).newInstance(context, map)
clazz.getConstructor(
Context::class.java,
TrackedMap3D::class.java,
).newInstance(context, map)
} catch (e: Exception) {
try {
clazz.getConstructor(TrackedMap3D::class.java).newInstance(map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import com.google.android.gms.maps3d.model.PopoverOptions
/**
* Decorator wrapper around GoogleMap3D to track elements added during a snippet session.
*/
class TrackedMap3D(
val delegate: GoogleMap3D,
private val items: MutableList<Any>,
) {
class TrackedMap3D(val delegate: GoogleMap3D, private val items: MutableList<Any>) {

fun addMarker(options: MarkerOptions): Marker? {
val marker = delegate.addMarker(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ package com.example.snippets.kotlin.annotations
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class SnippetGroup(
val title: String,
val description: String = "",
)
annotation class SnippetGroup(val title: String, val description: String = "")
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ package com.example.snippets.kotlin.annotations
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class SnippetItem(
val title: String,
val description: String = "",
)
annotation class SnippetItem(val title: String, val description: String = "")
Loading
Loading