diff --git a/snippets/app/src/gms/java/com/google/maps/example/MapsActivity.java b/snippets/app/src/gms/java/com/google/maps/example/MapsActivity.java index 2e61ee0f..6c90567a 100644 --- a/snippets/app/src/gms/java/com/google/maps/example/MapsActivity.java +++ b/snippets/app/src/gms/java/com/google/maps/example/MapsActivity.java @@ -14,11 +14,9 @@ package com.google.maps.example; - -import androidx.appcompat.app.AppCompatActivity; - +//[START maps_android_mapsactivity] import android.os.Bundle; - +import androidx.appcompat.app.AppCompatActivity; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; @@ -62,3 +60,4 @@ public class MapsActivity extends AppCompatActivity implements OnMapReadyCallbac mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); } } +//[END maps_android_mapsactivity] diff --git a/snippets/app/src/gms/java/com/google/maps/example/kotlin/MapsActivity.kt b/snippets/app/src/gms/java/com/google/maps/example/kotlin/MapsActivity.kt index 6a35bb29..339970e2 100644 --- a/snippets/app/src/gms/java/com/google/maps/example/kotlin/MapsActivity.kt +++ b/snippets/app/src/gms/java/com/google/maps/example/kotlin/MapsActivity.kt @@ -14,6 +14,7 @@ package com.google.maps.example.kotlin +//[START maps_android_mapsactivity] import androidx.appcompat.app.AppCompatActivity import android.os.Bundle @@ -59,4 +60,5 @@ internal class MapsActivity : AppCompatActivity(), OnMapReadyCallback { .title("Marker in Sydney")) mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)) } -} \ No newline at end of file +} +//[END maps_android_mapsactivity] diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle index 4aa270c7..33c78da7 100644 --- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle +++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle @@ -6,12 +6,12 @@ plugins { } android { - compileSdkVersion 29 - buildToolsVersion '28.0.3' + compileSdkVersion 31 + buildToolsVersion '30.0.2' defaultConfig { applicationId "com.example.currentplacedetailsonmap" - minSdkVersion 17 - targetSdkVersion 29 + minSdkVersion 19 + targetSdkVersion 31 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -33,7 +33,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.gms:play-services-maps:17.0.1' + implementation 'com.google.android.gms:play-services-maps:18.0.0' implementation 'com.google.android.libraries.places:places:2.5.0' implementation 'com.android.volley:volley:1.2.1' testImplementation'junit:junit:4.13' diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml index 09b6b05f..ed4f51c1 100644 --- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml +++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ package="com.example.currentplacedetailsonmap"> + diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt index b97ec431..94552ea3 100644 --- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt +++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt @@ -190,6 +190,7 @@ class MapsActivityCurrentPlace : AppCompatActivity(), OnMapReadyCallback { * Gets the current location of the device, and positions the map's camera. */ // [START maps_current_place_get_device_location] + @SuppressLint("MissingPermission") private fun getDeviceLocation() { /* * Get the best and most recent location of the device, which may be null in rare @@ -351,11 +352,15 @@ class MapsActivityCurrentPlace : AppCompatActivity(), OnMapReadyCallback { """.trimIndent() } + if (markerLatLng == null) { + return@OnClickListener + } + // Add a marker for the selected place, with an info window // showing information about that place. map?.addMarker(MarkerOptions() .title(likelyPlaceNames[which]) - .position(markerLatLng!!) + .position(markerLatLng) .snippet(markerSnippet)) // Position the map's camera at the location of the marker. @@ -375,6 +380,7 @@ class MapsActivityCurrentPlace : AppCompatActivity(), OnMapReadyCallback { * Updates the map's UI settings based on whether the user has granted location permission. */ // [START maps_current_place_update_location_ui] + @SuppressLint("MissingPermission") private fun updateLocationUI() { if (map == null) { return