Skip to content

Commit 8605030

Browse files
authored
Merge branch 'main' into feat/add-map-view-factory
2 parents efd47fb + 262b530 commit 8605030

File tree

21 files changed

+95
-42
lines changed

21 files changed

+95
-42
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
distribution: 'temurin'
4343

4444
- name: Build modules
45-
run: ./gradlew build jacocoTestReport --stacktrace
45+
run: ./gradlew build jacocoTestReport -x :maps-app:generateDebugScreenshotTestConfig -x :maps-app:testDebugScreenshotTest -x :maps-app:generateReleaseScreenshotTestConfig -x :maps-app:testReleaseScreenshotTest --stacktrace
4646

4747
- name: Run Screenshot Tests
4848
run: ./gradlew validateDebugScreenshotTest
@@ -51,5 +51,5 @@ jobs:
5151
uses: actions/upload-artifact@v4
5252
if: always()
5353
with:
54-
name: my-artifact
54+
name: screenshot-report
5555
path: maps-app/build/reports

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ Box(Modifier.fillMaxSize()) {
157157
}
158158
```
159159

160+
Remember that the map must load before any camera state can be set. If you are using a LaunchedEffect, you must wait until the map has been loaded:
161+
162+
```kotlin
163+
@Composable
164+
fun MapScreen() {
165+
var mapLoaded by remember { mutableStateOf(false) }
166+
167+
GoogleMap(
168+
modifier = Modifier.fillMaxSize(),
169+
onMapLoaded = { mapLoaded = true }
170+
)
171+
172+
if (mapLoaded) {
173+
LaunchedEffect(Unit) {
174+
// here the camera operations
175+
}
176+
}
177+
}
178+
```
179+
160180
</details>
161181

162182
<details>
@@ -477,6 +497,13 @@ Box(Modifier.fillMaxSize()) {
477497

478498
The colors of the text, line, and shadow are also all configurable (e.g., based on `isSystemInDarkTheme()` on a dark map). Similarly, the `DisappearingScaleBar` animations can be configured.
479499

500+
## Internal usage attribution ID
501+
502+
This library calls the MapsApiSettings.addInternalUsageAttributionId method, which helps Google
503+
understand which libraries and samples are helpful to developers and is optional. Instructions for
504+
opting out of the identifier are provided in
505+
[reference documentation](maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt).
506+
480507
## Contributing
481508

482509
Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].

gradle/libs.versions.toml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[versions]
22
activitycompose = "1.10.1"
3-
agp = "8.10.1"
4-
androidCore = "1.6.1"
5-
androidx-core = "1.16.0"
6-
androidxtest = "1.6.2"
7-
compose-bom = "2025.04.00"
3+
agp = "8.12.1"
4+
androidCore = "1.7.0"
5+
androidx-core = "1.17.0"
6+
androidxtest = "1.7.0"
7+
compose-bom = "2025.08.01"
88
dokka = "2.0.0"
9-
espresso = "3.6.1"
9+
espresso = "3.7.0"
1010
gradleMavenPublishPlugin = "0.34.0"
1111
jacoco-plugin = "0.2.1"
1212
junit = "4.13.2"
13-
junitktx = "1.2.1"
14-
kotlin = "2.2.0"
13+
junitktx = "1.3.0"
14+
kotlin = "2.2.10"
1515
kotlinxCoroutines = "1.10.2"
16-
leakcanaryAndroid = "2.12"
16+
leakcanaryAndroid = "2.14"
1717
mapsecrets = "2.0.1"
1818
mapsktx = "5.2.0"
19-
org-jacoco-core = "0.8.12"
20-
screenshot = "0.0.1-alpha10"
19+
org-jacoco-core = "0.8.13"
20+
screenshot = "0.0.1-alpha11"
2121
constraintlayout = "2.2.1"
2222
material = "1.12.0"
2323

@@ -52,6 +52,7 @@ org-jacoco-core = { module = "org.jacoco:org.jacoco.core", version.ref = "org-ja
5252
test-junit = { module = "junit:junit", version.ref = "junit" }
5353
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
5454
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
55+
screenshot-validation-api = { group = "com.android.tools.screenshot", name = "screenshot-validation-api", version.ref = "screenshot" }
5556

5657
[plugins]
5758
android-application = { id = "com.android.application", version.ref = "agp" }

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

maps-app/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ android {
2323
}
2424

2525
namespace = "com.google.maps.android.compose"
26-
compileSdk = 35
26+
compileSdk = 36
2727

2828
defaultConfig {
2929
minSdk = 21
30-
targetSdk = 35
30+
targetSdk = 36
3131
versionCode = 1
3232
versionName = "1.0"
3333
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -67,6 +67,7 @@ dependencies {
6767
implementation(libs.androidx.compose.ui.preview.tooling)
6868
implementation(libs.androidx.constraintlayout)
6969
implementation(libs.material)
70+
implementation(libs.screenshot.validation.api)
7071
debugImplementation(libs.androidx.compose.ui.tooling)
7172
debugImplementation(libs.leakcanary.android)
7273

maps-app/src/main/java/com/google/maps/android/compose/BasicMapActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ import androidx.compose.ui.graphics.Color
5858
import androidx.compose.ui.graphics.toArgb
5959
import androidx.compose.ui.platform.testTag
6060
import androidx.compose.ui.text.style.TextAlign
61-
import androidx.compose.ui.tooling.preview.Preview
6261
import androidx.compose.ui.unit.dp
62+
import com.android.tools.screenshot.PreviewTest
6363
import com.google.android.gms.maps.CameraUpdateFactory
6464
import com.google.android.gms.maps.model.BitmapDescriptorFactory
6565
import com.google.android.gms.maps.model.CameraPosition
@@ -433,7 +433,7 @@ private fun DebugView(
433433
}
434434

435435

436-
@Preview
436+
@PreviewTest
437437
@Composable
438438
fun GoogleMapViewPreview() {
439439
MapsComposeSampleTheme {

maps-app/src/main/java/com/google/maps/android/compose/LocationTrackingActivity.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,16 @@ class LocationTrackingActivity : ComponentActivity() {
9393
// Collect location updates
9494
val locationState = locationFlow.collectAsState(initial = newLocation())
9595

96-
// Update blue dot and camera when the location changes
97-
LaunchedEffect(locationState.value) {
98-
Log.d(TAG, "Updating blue dot on map...")
99-
locationSource.onLocationChanged(locationState.value)
100-
101-
Log.d(TAG, "Updating camera position...")
102-
val cameraPosition = CameraPosition.fromLatLngZoom(LatLng(locationState.value.latitude, locationState.value.longitude), zoom)
103-
cameraPositionState.animate(CameraUpdateFactory.newCameraPosition(cameraPosition), 1_000)
96+
if (isMapLoaded) {
97+
// Update blue dot and camera when the location changes
98+
LaunchedEffect(locationState.value) {
99+
Log.d(TAG, "Updating blue dot on map...")
100+
locationSource.onLocationChanged(locationState.value)
101+
102+
Log.d(TAG, "Updating camera position...")
103+
val cameraPosition = CameraPosition.fromLatLngZoom(LatLng(locationState.value.latitude, locationState.value.longitude), zoom)
104+
cameraPositionState.animate(CameraUpdateFactory.newCameraPosition(cameraPosition), 1_000)
105+
}
104106
}
105107

106108
// Detect when the map starts moving and print the reason

0 commit comments

Comments
 (0)