mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
chore: Add maps_android_mapsactivity region tag. (#747)
Change-Id: I642a4bd8624d6665f5eb2720079e321880581aa6
This commit is contained in:
parent
15b409a16c
commit
c8a7ec1127
@ -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]
|
||||
|
||||
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
//[END maps_android_mapsactivity]
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
package="com.example.currentplacedetailsonmap">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -39,6 +40,7 @@
|
||||
|
||||
<activity
|
||||
android:name="com.example.currentplacedetailsonmap.MapsActivityCurrentPlace"
|
||||
android:exported="true"
|
||||
android:label="@string/title_activity_maps">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user