Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Google LLC
// 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.
Expand Down Expand Up @@ -36,6 +36,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.sp
Expand All @@ -47,8 +48,8 @@ import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.compose.GoogleMap
import com.google.maps.android.compose.Marker
import com.google.maps.android.compose.MarkerState
import com.google.maps.android.compose.rememberCameraPositionState
import com.google.maps.android.compose.rememberUpdatedMarkerState
import dagger.hilt.android.AndroidEntryPoint

import androidx.core.view.WindowCompat
Expand Down Expand Up @@ -149,13 +150,16 @@ fun MapScreen(modifier: Modifier = Modifier) {
cameraPositionState = cameraPositionState
) {
markers.forEach { markerData ->
Marker(
state = remember(markerData.id) {
MarkerState(position = LatLng(markerData.latitude, markerData.longitude))
},
title = markerData.label,
icon = BitmapDescriptorFactory.defaultMarker(markerData.color)
)
key(markerData.id) {
val markerState = rememberUpdatedMarkerState(
position = LatLng(markerData.latitude, markerData.longitude)
)
Marker(
state = markerState,
title = markerData.label,
icon = BitmapDescriptorFactory.defaultMarker(markerData.color)
)
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mapsCompose = "8.4.0"
mapsKtx = "6.3.0"
mapsUtils = "5.1.1"
places = "5.3.0"
playServicesLocation = "21.4.0"
playServicesMaps = "20.0.0"
secretsGradlePlugin = "2.0.1"

Expand Down Expand Up @@ -106,6 +107,7 @@ maps-ktx = { group = "com.google.maps.android", name = "maps-ktx", version.ref =
maps-utils = { module = "com.google.maps.android:android-maps-utils", version.ref = "mapsUtils" }
maps-utils-ktx = { group = "com.google.maps.android", name = "maps-utils-ktx", version.ref = "mapsKtx" }
places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" }
play-services-location = { group = "com.google.android.gms", name = "play-services-location", version.ref = "playServicesLocation" }
play-services-maps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }

# Wear OS
Expand Down
3 changes: 2 additions & 1 deletion snippets/app-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down Expand Up @@ -36,6 +36,7 @@ android {
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
3 changes: 2 additions & 1 deletion snippets/app-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down Expand Up @@ -42,6 +42,7 @@ android {
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// 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.
Expand Down Expand Up @@ -68,7 +68,7 @@ internal class KML {
// [START maps_android_utils_kml_access_properties]
for (container in layer.getContainers()) {
if (container.hasProperty("name")) {
Log.i("KML", container.getProperty("name")!!)
Log.i("KML", container.getProperty("name") ?: "")
}
}
// [END maps_android_utils_kml_access_properties]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// 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.
Expand Down Expand Up @@ -35,26 +35,26 @@ import org.xmlpull.v1.XmlPullParserException
import java.io.IOException

internal class Multilayer {
private val map: GoogleMap? = null
private val context: Context? = null
private lateinit var map: GoogleMap
private lateinit var context: Context

@Suppress("IndexOutOfBoundsException")
@Throws(IOException::class, JSONException::class, XmlPullParserException::class)
private fun init() {
// [START maps_android_utils_multilayer_init]
val markerManager = MarkerManager(map)
val groundOverlayManager = GroundOverlayManager(map!!)
val groundOverlayManager = GroundOverlayManager(map)
val polygonManager = PolygonManager(map)
val polylineManager = PolylineManager(map)
// [END maps_android_utils_multilayer_init]

// [START maps_android_utils_multilayer_manager]
val clusterManager =
ClusterManager<MyItem>(context!!, map, markerManager)
ClusterManager<MyItem>(context, map, markerManager)
val geoJsonLineLayer = GeoJsonLayer(
map,
R.raw.geojson_file,
context!!,
context,
markerManager,
polygonManager,
polylineManager,
Expand All @@ -63,7 +63,7 @@ internal class Multilayer {
val kmlPolylineLayer = KmlLayer(
map,
R.raw.kml_file,
context!!,
context,
markerManager,
polygonManager,
polylineManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// 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.
Expand All @@ -23,6 +23,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;

class TileOverlays implements OnMapReadyCallback {
// [START maps_android_tile_overlays_add]
Expand All @@ -34,7 +35,7 @@ class TileOverlays implements OnMapReadyCallback {
public URL getTileUrl(int x, int y, int zoom) {

/* Define the URL pattern for the tile images */
String s = String.format("http://my.image.server/images/%d/%d/%d.png", zoom, x, y);
String s = String.format(Locale.US, "http://my.image.server/images/%d/%d/%d.png", zoom, x, y);

if (!checkTileExists(x, y, zoom)) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions tutorials/java/Polygons/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down Expand Up @@ -28,7 +28,7 @@ android {
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = libs.versions.versionCode.get().toInt()
versionName = libs.versions.versionName.get()
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

/*
* Copyright 2024 Google LLC
* 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.
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
testImplementation(libs.junit)
implementation(libs.coreKtx)
implementation(libs.lifecycleViewModelKtx)
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${libs.versions.kotlin.get()}")
implementation(libs.kotlin.stdlib)
implementation(libs.material)
}

Expand Down
4 changes: 2 additions & 2 deletions tutorials/kotlin/Polygons/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

/*
* Copyright 2024 Google LLC
* 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.
Expand Down Expand Up @@ -30,7 +30,7 @@ android {
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = libs.versions.versionCode.get().toInt()
versionName = libs.versions.versionName.get()
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// 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.
Expand Down Expand Up @@ -185,7 +185,7 @@ class PolyActivity : AppCompatActivity(), OnMapReadyCallback, OnPolylineClickLis
// The default pattern is a solid stroke.
polyline.pattern = null
}
Toast.makeText(this, "Route type " + polyline.tag.toString(),
Toast.makeText(this, "Route type ${polyline.tag}",
Toast.LENGTH_SHORT).show()
}
// [END maps_poly_activity_on_polyline_click]
Expand Down