Google Map

Copy Icons

To keep our application size and build-time reasonable, we never want to include the full extended icon set. We'll copy the icons that we don't have.

We'll do this the same way we did for the Movie example.

Code Changes

CHANGED: /app/build.gradle.kts
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.secrets)
} kotlin { jvmToolchain(17) } android { namespace = "com.androidbyexample.googlemap" compileSdk = 34 defaultConfig { applicationId = "com.androidbyexample.googlemap" minSdk = 24 targetSdk = 34 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" ) } } buildFeatures { compose = true } composeOptions { kotlinCompilerExtensionVersion = "1.5.3" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } } dependencies {
// implementation(libs.icons.extended)// implementation(libs.icons.extended)
implementation(libs.location.services) implementation(libs.runtime.compose)
implementation(libs.maps.compose) implementation(libs.maps.compose.utils)
implementation(libs.core.ktx) implementation(libs.lifecycle.runtime.ktx) implementation(libs.activity.compose) implementation(platform(libs.compose.bom)) implementation(libs.ui) implementation(libs.ui.graphics) implementation(libs.ui.tooling.preview) implementation(libs.material3) testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(libs.espresso.core) androidTestImplementation(platform(libs.compose.bom)) androidTestImplementation(libs.ui.test.junit4) debugImplementation(libs.ui.tooling) debugImplementation(libs.ui.test.manifest) }
ADDED: /app/src/main/java/androidx/compose/material/icons/filled/DirectionsWalk.kt
/* * Copyright 2023 The Android Open Source Project * * 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 androidx.compose.material.icons.filledimport androidx.compose.material.icons.Iconsimport androidx.compose.material.icons.materialIconimport androidx.compose.material.icons.materialPathimport androidx.compose.ui.graphics.vector.ImageVectorimport kotlin.Deprecated@Deprecated(    "Use the AutoMirrored version at Icons.AutoMirrored.Filled.DirectionsWalk",    ReplaceWith( "Icons.AutoMirrored.Filled.DirectionsWalk",        "androidx.compose.material.icons.automirrored.filled.DirectionsWalk"),)public val Icons.Filled.DirectionsWalk: ImageVector    get() {        if (_directionsWalk != null) {            return _directionsWalk!!        }        _directionsWalk = materialIcon(name = "Filled.DirectionsWalk") {            materialPath {                moveTo(13.5f, 5.5f)                curveToRelative(1.1f, 0.0f, 2.0f, -0.9f, 2.0f, -2.0f)                reflectiveCurveToRelative(-0.9f, -2.0f, -2.0f, -2.0f)                reflectiveCurveToRelative(-2.0f, 0.9f, -2.0f, 2.0f)                reflectiveCurveToRelative(0.9f, 2.0f, 2.0f, 2.0f)                close()                moveTo(9.8f, 8.9f)                lineTo(7.0f, 23.0f)                horizontalLineToRelative(2.1f)                lineToRelative(1.8f, -8.0f)                lineToRelative(2.1f, 2.0f)                verticalLineToRelative(6.0f)                horizontalLineToRelative(2.0f)                verticalLineToRelative(-7.5f)                lineToRelative(-2.1f, -2.0f)                lineToRelative(0.6f, -3.0f)                curveTo(14.8f, 12.0f, 16.8f, 13.0f, 19.0f, 13.0f)                verticalLineToRelative(-2.0f)                curveToRelative(-1.9f, 0.0f, -3.5f, -1.0f, -4.3f, -2.4f)                lineToRelative(-1.0f, -1.6f)                curveToRelative(-0.4f, -0.6f, -1.0f, -1.0f, -1.7f, -1.0f)                curveToRelative(-0.3f, 0.0f, -0.5f, 0.1f, -0.8f, 0.1f)                lineTo(6.0f, 8.3f)                verticalLineTo(13.0f)                horizontalLineToRelative(2.0f)                verticalLineTo(9.6f)                lineToRelative(1.8f, -0.7f)            }        }        return _directionsWalk!!    }private var _directionsWalk: ImageVector? = null
ADDED: /app/src/main/java/androidx/compose/material/icons/filled/GpsFixed.kt
/* * Copyright 2023 The Android Open Source Project * * 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 androidx.compose.material.icons.filledimport androidx.compose.material.icons.Iconsimport androidx.compose.material.icons.materialIconimport androidx.compose.material.icons.materialPathimport androidx.compose.ui.graphics.vector.ImageVectorpublic val Icons.Filled.GpsFixed: ImageVector    get() {        if (_gpsFixed != null) {            return _gpsFixed!!        }        _gpsFixed = materialIcon(name = "Filled.GpsFixed") {            materialPath {                moveTo(12.0f, 8.0f)                curveToRelative(-2.21f, 0.0f, -4.0f, 1.79f, -4.0f, 4.0f)                reflectiveCurveToRelative(1.79f, 4.0f, 4.0f, 4.0f)                reflectiveCurveToRelative(4.0f, -1.79f, 4.0f, -4.0f)                reflectiveCurveToRelative(-1.79f, -4.0f, -4.0f, -4.0f)                close()                moveTo(20.94f, 11.0f)                curveToRelative(-0.46f, -4.17f, -3.77f, -7.48f, -7.94f, -7.94f)                lineTo(13.0f, 1.0f)                horizontalLineToRelative(-2.0f)                verticalLineToRelative(2.06f)                curveTo(6.83f, 3.52f, 3.52f, 6.83f, 3.06f, 11.0f)                lineTo(1.0f, 11.0f)                verticalLineToRelative(2.0f)                horizontalLineToRelative(2.06f)                curveToRelative(0.46f, 4.17f, 3.77f, 7.48f, 7.94f, 7.94f)                lineTo(11.0f, 23.0f)                horizontalLineToRelative(2.0f)                verticalLineToRelative(-2.06f)                curveToRelative(4.17f, -0.46f, 7.48f, -3.77f, 7.94f, -7.94f)                lineTo(23.0f, 13.0f)                verticalLineToRelative(-2.0f)                horizontalLineToRelative(-2.06f)                close()                moveTo(12.0f, 19.0f)                curveToRelative(-3.87f, 0.0f, -7.0f, -3.13f, -7.0f, -7.0f)                reflectiveCurveToRelative(3.13f, -7.0f, 7.0f, -7.0f)                reflectiveCurveToRelative(7.0f, 3.13f, 7.0f, 7.0f)                reflectiveCurveToRelative(-3.13f, 7.0f, -7.0f, 7.0f)                close()            }        }        return _gpsFixed!!    }private var _gpsFixed: ImageVector? = null
CHANGED: /app/src/main/java/com/androidbyexample/googlemap/CarTopBar.kt
@file:OptIn(ExperimentalMaterial3Api::class)

package com.androidbyexample.googlemap

import android.location.Location
import androidx.compose.material.icons.Icons
//import androidx.compose.material.icons.automirrored.filled.DirectionsWalkimport androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.DirectionsWalk
import androidx.compose.material.icons.filled.GpsFixed
import androidx.compose.material.icons.filled.Star
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.google.android.gms.maps.model.LatLng

@Composable fun CarTopBar( currentLocation: Location?, carLatLng: LatLng?, onSetCarLocation: () -> Unit, onGoToCurrentLocation: () -> Unit, onClearCarLocation: () -> Unit, onWalkToCar: () -> Unit, ) { TopAppBar( title = { Text(text = stringResource(id = R.string.app_name)) }, actions = { currentLocation?.let { IconButton(onClick = onGoToCurrentLocation) { Icon( imageVector = Icons.Filled.GpsFixed, contentDescription = stringResource(id = R.string.go_to_current_location), ) } IconButton(onClick = onSetCarLocation) { Icon( imageVector = Icons.Filled.Star, contentDescription = stringResource(id = R.string.remember_location), ) } } carLatLng?.let { IconButton(onClick = onWalkToCar) { Icon( // imageVector = Icons.AutoMirrored.Filled.DirectionsWalk, imageVector = Icons.Filled.DirectionsWalk, contentDescription = stringResource(id = R.string.navigate), ) } IconButton(onClick = onClearCarLocation) { Icon( imageVector = Icons.Filled.Delete, contentDescription = stringResource(id = R.string.forget_location), ) } } }, ) }