Update to latest Maps and Places SDKs (#141)

* Update ApiDemos/java to latest Maps SDK for Android

* Update ApiDemos/kotlin to latest Maps SDK for Android

* Update tutorials/CurrentPlaceDetailsOnMap to new Places SDK for Android

* Update tutorials/MapWithMarker to latest Maps SDK for Android

* Update tutorials/Polygons to latest Maps SDK for Android

* Update tutorials/StyledMap to latest Maps SDK for Android

* Update README with better instructions for API key
This commit is contained in:
Angela Yu 2019-12-30 13:18:01 -08:00 committed by GitHub
parent 2a5dd33154
commit 7e9b01cf82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 319 additions and 261 deletions

View File

@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'project-report'
android {
compileSdkVersion 27
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.mapdemo"
minSdkVersion 15
targetSdkVersion 27
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
@ -22,10 +22,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.android.support:support-v4:27.0.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Needed for the LiteListDemo
implementation "com.android.support:recyclerview-v7:27.0.2"
implementation "androidx.recyclerview:recyclerview:1.1.0"
}

View File

@ -3,7 +3,7 @@
TODO: Before you run your application, you need a Google Maps API key.
See this page for more information:
https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
@ -12,6 +12,6 @@
the demo app.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
YOUR_KEY_HERE
YOUR_API_KEY
</string>
</resources>

View File

@ -23,7 +23,8 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with a map and a marker on the map.

View File

@ -26,11 +26,12 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to constrain the camera to specific boundaries and zoom levels.
*/

View File

@ -32,13 +32,14 @@ import com.google.android.gms.maps.model.PolylineOptions;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to change the camera position for the map.
*/

View File

@ -37,7 +37,6 @@ import android.graphics.Color;
import android.graphics.Point;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -47,6 +46,8 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

View File

@ -16,7 +16,7 @@
package com.example.mapdemo;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* A simple POJO that holds the details about the demo that are used by the List Adapter.

View File

@ -25,9 +25,10 @@ import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to listen to some {@link GoogleMap} events.
*/

View File

@ -27,12 +27,13 @@ import com.google.android.gms.maps.model.GroundOverlayOptions;
import com.google.android.gms.maps.model.LatLng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;

View File

@ -24,10 +24,11 @@ import com.google.android.gms.maps.model.IndoorLevel;
import com.google.android.gms.maps.model.LatLng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.List;
/**

View File

@ -23,9 +23,6 @@ import com.google.android.gms.maps.SupportMapFragment;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
@ -35,6 +32,10 @@ import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_HYBRID;
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NONE;
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL;

View File

@ -28,9 +28,10 @@ import com.google.android.gms.maps.model.PolylineOptions;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
/**
* This demo shows some features supported in lite mode.
* In particular it demonstrates the use of {@link com.google.android.gms.maps.model.Marker}s to

View File

@ -25,16 +25,16 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* This shows to include a map in lite mode in a ListView.

View File

@ -25,7 +25,8 @@ import com.google.android.gms.maps.model.LatLng;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to use a custom location source.

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@ -28,6 +27,8 @@ import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
/**
* The main activity of the API library demo gallery.
* <p>

View File

@ -19,15 +19,15 @@ package com.example.mapdemo;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
/**
* This shows how to add a map to a ViewPager. Note the use of
* {@link ViewGroup#requestTransparentRegion(View)} to reduce jankiness.

View File

@ -27,7 +27,8 @@ import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to close the info window when the currently selected marker is re-tapped.

View File

@ -39,11 +39,12 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;

View File

@ -17,7 +17,8 @@
package com.example.mapdemo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with multiple maps on screen.

View File

@ -26,10 +26,11 @@ import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.widget.Toast;
/**

View File

@ -17,7 +17,8 @@
package com.example.mapdemo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* An activity that creates a map with some initial options.

View File

@ -22,9 +22,10 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.DialogFragment;
import android.widget.Toast;
/**
@ -37,7 +38,7 @@ public abstract class PermissionUtils {
* be shown to the user, displays a dialog that triggers the request.
*/
public static void requestPermission(AppCompatActivity activity, int requestId,
String permission, boolean finishActivity) {
String permission, boolean finishActivity) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// Display a dialog with rationale.
PermissionUtils.RationaleDialog.newInstance(requestId, finishActivity)
@ -53,7 +54,7 @@ public abstract class PermissionUtils {
* Checks if the result contains a {@link PackageManager#PERMISSION_GRANTED} result for a
* permission from a runtime permissions request.
*
* @see android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback
* @see androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback
*/
public static boolean isPermissionGranted(String[] grantPermissions, int[] grantResults,
String permission) {
@ -113,7 +114,7 @@ public abstract class PermissionUtils {
* permission.
* <p>
* The activity should implement
* {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}
* {@link androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback}
* to handle permit or denial of this permission request.
*/
public static class RationaleDialog extends DialogFragment {
@ -132,7 +133,7 @@ public abstract class PermissionUtils {
*
* @param requestCode Id of the request that is used to request the permission. It is
* returned to the
* {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}.
* {@link androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback}.
* @param finishActivity Whether the calling Activity should be finished if the dialog is
* cancelled.
*/

View File

@ -31,7 +31,6 @@ import com.google.android.gms.maps.model.PolygonOptions;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -41,6 +40,8 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays;
import java.util.List;

View File

@ -37,7 +37,6 @@ import com.google.android.gms.maps.model.SquareCap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -47,6 +46,8 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays;
import java.util.List;

View File

@ -23,8 +23,9 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
/**
* Demonstrates how to instantiate a SupportMapFragment programmatically and add a marker to it.

View File

@ -23,7 +23,8 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with a raw MapView and add a marker to it. This

View File

@ -23,7 +23,8 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to retain a map across activity restarts (e.g., from screen rotations), which can

View File

@ -30,7 +30,8 @@ import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Random;

View File

@ -24,11 +24,12 @@ import com.google.android.gms.maps.SupportMapFragment;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to take a snapshot of the map.
*/

View File

@ -31,7 +31,8 @@ import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.StreetViewPanoramaLocation;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with streetview and a map

View File

@ -22,7 +22,8 @@ import com.google.android.gms.maps.SupportStreetViewPanoramaFragment;
import com.google.android.gms.maps.model.LatLng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with streetview

View File

@ -30,9 +30,10 @@ import com.google.android.gms.maps.model.StreetViewPanoramaOrientation;
import android.graphics.Point;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to listen to some {@link StreetViewPanorama} events.
*/

View File

@ -25,11 +25,13 @@ import com.google.android.gms.maps.model.StreetViewPanoramaLink;
import com.google.android.gms.maps.model.StreetViewPanoramaLocation;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create an activity with access to all the options in Panorama
* which can be adjusted dynamically

View File

@ -22,11 +22,12 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.StreetViewSource;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create an activity with static streetview (all options have been switched off)
*/

View File

@ -21,9 +21,10 @@ import com.google.android.gms.maps.StreetViewPanoramaView;
import com.google.android.gms.maps.model.LatLng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup.LayoutParams;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with streetview
*/

View File

@ -25,13 +25,14 @@ import com.google.android.gms.maps.model.MapStyleOptions;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;

View File

@ -18,8 +18,10 @@ package com.example.mapdemo;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
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.GoogleMap.OnCircleClickListener;

View File

@ -28,7 +28,8 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import java.io.ByteArrayOutputStream;

View File

@ -25,12 +25,13 @@ import com.google.android.gms.maps.model.TileProvider;
import com.google.android.gms.maps.model.UrlTileProvider;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import androidx.appcompat.app.AppCompatActivity;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;

View File

@ -24,10 +24,11 @@ import com.google.android.gms.maps.UiSettings;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;

View File

@ -27,13 +27,14 @@ import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to use setPadding to allow overlays that obscure part of the map without
* obscuring the map UI or copyright notices.

View File

@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:scrollbars="vertical"

View File

@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.viewpager.widget.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
android:layout_height="match_parent"></androidx.viewpager.widget.ViewPager>

View File

@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true

View File

@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
compileSdkVersion 29
defaultConfig {
applicationId "com.example.kotlindemos"
minSdkVersion 15
targetSdkVersion 27
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -24,18 +24,18 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// This dependency is needed to use RecyclerView, for the LiteListDemoActivity
implementation "com.android.support:recyclerview-v7:27.0.2"
// CardView is used in the LiteListDemoActivity
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// Below is the Google Play Services dependency required for using the Google Maps Android API
implementation 'com.google.android.gms:play-services-maps:11.8.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Needed for the LiteListDemo
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// Below is used to run the easypermissions library to manage location permissions
// EasyPermissions is needed to help us request for permission to access location
implementation 'pub.devrel:easypermissions:1.1.1'

View File

@ -3,7 +3,7 @@
TODO: Before you run your application, you need a Google Maps API key.
See this page for more information:
https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key
https://developers.google.com/maps/gmp-get-started
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
@ -12,6 +12,6 @@
the demo app.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
ADD_YOUR_KEY_HERE
YOUR_API_KEY
</string>
</resources>

View File

@ -16,9 +16,8 @@
package com.example.kotlindemos
import android.support.v7.app.AppCompatActivity
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

View File

@ -18,12 +18,12 @@ package com.example.kotlindemos
import android.graphics.Color
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.CompoundButton
import android.widget.SeekBar
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdate
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap

View File

@ -19,7 +19,6 @@ package com.example.kotlindemos
import android.graphics.Color
import android.graphics.Point
import android.location.Location
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.AdapterView
@ -28,6 +27,9 @@ import android.widget.CheckBox
import android.widget.SeekBar
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
@ -209,7 +211,7 @@ class CircleDemoActivity :
setContentDescription(getString(R.string.circle_demo_details))
setOnMapLongClickListener { point ->
// We know the center, let's place the outline at a point 3/4 along the view.
val view: View = supportFragmentManager.findFragmentById(R.id.map).view
val view: View = supportFragmentManager.findFragmentById(R.id.map)?.view
?: return@setOnMapLongClickListener
val radiusLatLng = map.projection.fromScreenLocation(
Point(view.height * 3 / 4, view.width * 3 / 4))

View File

@ -16,8 +16,8 @@
package com.example.kotlindemos
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.kotlindemos.OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap

View File

@ -16,7 +16,7 @@
package com.example.kotlindemos
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
/**

View File

@ -20,13 +20,13 @@ import android.Manifest
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.CheckBox
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.GoogleMap.MAP_TYPE_HYBRID
import com.google.android.gms.maps.GoogleMap.MAP_TYPE_NONE

View File

@ -17,10 +17,6 @@
package com.example.kotlindemos
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
@ -28,6 +24,10 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.MapsInitializer
@ -102,8 +102,8 @@ class LiteListDemoActivity : AppCompatActivity() {
*/
inner class MapAdapter : RecyclerView.Adapter<MapAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
holder?.bindView(position) ?: return
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bindView(position)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

View File

@ -16,9 +16,9 @@
package com.example.kotlindemos
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
@ -26,6 +26,7 @@ import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.ListAdapter
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
/**
* The main activity of the API library demo gallery.
@ -58,15 +59,18 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
* @property context current activity
* @property demos An array containing the details of the demos to be displayed.
*/
@SuppressLint("ResourceType")
class CustomArrayAdapter(context: Context, demos: List<DemoDetails>) :
ArrayAdapter<DemoDetails>(context, R.id.title, demos) {
ArrayAdapter<DemoDetails>(context, R.layout.feature, demos) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val demo: DemoDetails = getItem(position)
val demo: DemoDetails? = getItem(position)
return (convertView as? FeatureView ?: FeatureView(context)).apply {
setTitleId(demo.titleId)
setDescriptionId(demo.descriptionId)
contentDescription = resources.getString(demo.titleId)
if (demo != null) {
setTitleId(demo.titleId)
setDescriptionId(demo.descriptionId)
contentDescription = resources.getString(demo.titleId)
}
}
}
}

View File

@ -20,15 +20,9 @@ import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.media.Image
import android.os.Bundle
import android.os.Handler
import android.os.SystemClock
import android.support.annotation.ColorInt
import android.support.annotation.DrawableRes
import android.support.v4.content.res.ResourcesCompat
import android.support.v4.graphics.drawable.DrawableCompat
import android.support.v7.app.AppCompatActivity
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.util.Log
@ -41,6 +35,11 @@ import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter

View File

@ -19,13 +19,13 @@ package com.example.kotlindemos
import android.graphics.Color
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.AdapterView
import android.widget.SeekBar
import android.widget.Spinner
import android.widget.CheckBox
import android.widget.ArrayAdapter
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.model.Dash
import com.google.android.gms.maps.model.Dot

View File

@ -36,13 +36,13 @@ import com.google.android.gms.maps.model.RoundCap
import com.google.android.gms.maps.model.SquareCap
import android.graphics.Color
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.CheckBox
import android.widget.SeekBar
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity
import java.util.Arrays
/**

View File

@ -16,11 +16,11 @@
package com.example.kotlindemos
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.SeekBar
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.StreetViewPanorama
import com.google.android.gms.maps.SupportStreetViewPanoramaFragment
import com.google.android.gms.maps.model.LatLng

View File

@ -18,8 +18,8 @@ package com.example.kotlindemos
import android.graphics.Color
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.TextView
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.SupportMapFragment

View File

@ -18,10 +18,10 @@ package com.example.kotlindemos
import android.Manifest
import android.annotation.SuppressLint
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.CheckBox
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment

View File

@ -16,6 +16,15 @@
package com.example.kotlindemos
import android.os.Bundle
import android.os.Handler
import android.os.SystemClock
import android.view.View
import android.view.animation.OvershootInterpolator
import android.widget.Button
import android.widget.TextView
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.SupportMapFragment
@ -23,15 +32,6 @@ import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.LatLngBounds
import com.google.android.gms.maps.model.MarkerOptions
import android.os.Bundle
import android.os.Handler
import android.os.SystemClock
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.view.animation.OvershootInterpolator
import android.widget.Button
import android.widget.TextView
/**
* This shows how to use setPadding to allow overlays that obscure part of the map without
* obscuring the map UI or copyright notices.
@ -103,7 +103,7 @@ class VisibleRegionDemoActivity :
// increases the amount of padding along the right and bottom of the map
morePaddedButton.setOnClickListener {
// get the view that contains the map
val mapView: View? = supportFragmentManager.findFragmentById(R.id.map).view
val mapView: View? = supportFragmentManager.findFragmentById(R.id.map)?.view
animatePadding(150, 0, (mapView?.width ?: 0) / 3,
(mapView?.height ?: 0)/ 4)
}

View File

@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"

View File

@ -23,7 +23,7 @@
android:paddingTop="5dp">
<!-- Put the name of the location and the map inside a CardView -->
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
@ -52,5 +52,5 @@
map:mapType="none"
android:layout_below="@id/lite_listrow_text" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
</LinearLayout>

View File

@ -3,7 +3,7 @@
TODO: Before you run your application, you need a Google Maps API key.
See this page for more information:
https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key
https://developers.google.com/maps/gmp-get-started
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
@ -12,6 +12,6 @@
the demo app.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
"ADD_YOUR_KEY_HERE"
YOUR_API_KEY
</string>
</resources>

View File

@ -15,3 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true

View File

@ -1,12 +1,12 @@
Google Maps Android API v2 Samples
Google Maps SDK for Android Samples
===================================
Samples demonstrating how to use
[Google Maps Platform SDK for Android v2](https://developers.google.com/maps/documentation/android/).
[Maps SDK for Android](https://developers.google.com/maps/documentation/android/).
This repo contains the following samples:
1. [ApiDemos](ApiDemos): A collection of small demos showing most features of the Google Maps Android API. (This was formally part of the Google Play Services SDK.)
1. [ApiDemos](ApiDemos): A collection of small demos showing most features of the Maps SDK for Android.
1. [WearOS](WearOS):
Displays a map on a Wear OS device. This sample demonstrates the basic
setup required for a gradle-based Android Studio project.
@ -36,8 +36,10 @@ If prompted for a gradle configuration accept the default settings.
Alternatively use the "gradlew build" command to build the project directly.
Add your API key to the `AndroidManifest.xml` file.
See the [quick guide to getting an API key](https://developers.google.com/maps/documentation/android-api/signup).
Search for `YOUR_API_KEY` in the project and replace it with your API key.
Some samples store this in the gradle.properties file and others store it in the google_maps_api.xml file.
See the [Get Started with Google Maps Platform](https://developers.google.com/maps/gmp-get-started)
guide to get an API key.
Support
-------

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.currentplacedetailsonmap"
minSdkVersion 15
targetSdkVersion 25
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -28,7 +28,8 @@ dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.1.1'
implementation 'com.google.android.gms:play-services:11.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.libraries.places:places:2.1.0'
testImplementation'junit:junit:4.12'
}

View File

@ -4,11 +4,7 @@ import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@ -16,13 +12,14 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.places.GeoDataClient;
import com.google.android.gms.location.places.PlaceDetectionClient;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.location.places.PlaceLikelihoodBufferResponse;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
@ -34,6 +31,16 @@ import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.PlaceLikelihood;
import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest;
import com.google.android.libraries.places.api.net.FindCurrentPlaceResponse;
import com.google.android.libraries.places.api.net.PlacesClient;
import java.util.Arrays;
import java.util.List;
/**
* An activity that displays a map showing the place at the device's current location.
*/
@ -44,9 +51,8 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
private GoogleMap mMap;
private CameraPosition mCameraPosition;
// The entry points to the Places API.
private GeoDataClient mGeoDataClient;
private PlaceDetectionClient mPlaceDetectionClient;
// The entry point to the Places API.
private PlacesClient mPlacesClient;
// The entry point to the Fused Location Provider.
private FusedLocationProviderClient mFusedLocationProviderClient;
@ -70,7 +76,7 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
private static final int M_MAX_ENTRIES = 5;
private String[] mLikelyPlaceNames;
private String[] mLikelyPlaceAddresses;
private String[] mLikelyPlaceAttributions;
private List[] mLikelyPlaceAttributions;
private LatLng[] mLikelyPlaceLatLngs;
@Override
@ -86,11 +92,9 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
// Retrieve the content view that renders the map.
setContentView(R.layout.activity_maps);
// Construct a GeoDataClient.
mGeoDataClient = Places.getGeoDataClient(this, null);
// Construct a PlaceDetectionClient.
mPlaceDetectionClient = Places.getPlaceDetectionClient(this, null);
// Construct a PlacesClient
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
mPlacesClient = Places.createClient(this);
// Construct a FusedLocationProviderClient.
mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
@ -162,10 +166,10 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
View infoWindow = getLayoutInflater().inflate(R.layout.custom_info_contents,
(FrameLayout) findViewById(R.id.map), false);
TextView title = ((TextView) infoWindow.findViewById(R.id.title));
TextView title = infoWindow.findViewById(R.id.title);
title.setText(marker.getTitle());
TextView snippet = ((TextView) infoWindow.findViewById(R.id.snippet));
TextView snippet = infoWindow.findViewById(R.id.snippet);
snippet.setText(marker.getSnippet());
return infoWindow;
@ -199,9 +203,11 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
if (task.isSuccessful()) {
// Set the map's camera position to the current location of the device.
mLastKnownLocation = task.getResult();
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(mLastKnownLocation.getLatitude(),
mLastKnownLocation.getLongitude()), DEFAULT_ZOOM));
if (mLastKnownLocation != null) {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(mLastKnownLocation.getLatitude(),
mLastKnownLocation.getLongitude()), DEFAULT_ZOOM));
}
} else {
Log.d(TAG, "Current location is null. Using defaults.");
Log.e(TAG, "Exception: %s", task.getException());
@ -243,7 +249,7 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
*/
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String permissions[],
@NonNull String[] permissions,
@NonNull int[] grantResults) {
mLocationPermissionGranted = false;
switch (requestCode) {
@ -268,59 +274,62 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
}
if (mLocationPermissionGranted) {
// Use fields to define the data types to return.
List<Place.Field> placeFields = Arrays.asList(Place.Field.NAME, Place.Field.ADDRESS,
Place.Field.LAT_LNG);
// Use the builder to create a FindCurrentPlaceRequest.
FindCurrentPlaceRequest request =
FindCurrentPlaceRequest.newInstance(placeFields);
// Get the likely places - that is, the businesses and other points of interest that
// are the best match for the device's current location.
@SuppressWarnings("MissingPermission") final
Task<PlaceLikelihoodBufferResponse> placeResult =
mPlaceDetectionClient.getCurrentPlace(null);
placeResult.addOnCompleteListener
(new OnCompleteListener<PlaceLikelihoodBufferResponse>() {
@Override
public void onComplete(@NonNull Task<PlaceLikelihoodBufferResponse> task) {
if (task.isSuccessful() && task.getResult() != null) {
PlaceLikelihoodBufferResponse likelyPlaces = task.getResult();
Task<FindCurrentPlaceResponse> placeResult =
mPlacesClient.findCurrentPlace(request);
placeResult.addOnCompleteListener (new OnCompleteListener<FindCurrentPlaceResponse>() {
@Override
public void onComplete(@NonNull Task<FindCurrentPlaceResponse> task) {
if (task.isSuccessful() && task.getResult() != null) {
FindCurrentPlaceResponse likelyPlaces = task.getResult();
// Set the count, handling cases where less than 5 entries are returned.
int count;
if (likelyPlaces.getCount() < M_MAX_ENTRIES) {
count = likelyPlaces.getCount();
} else {
count = M_MAX_ENTRIES;
}
// Set the count, handling cases where less than 5 entries are returned.
int count;
if (likelyPlaces.getPlaceLikelihoods().size() < M_MAX_ENTRIES) {
count = likelyPlaces.getPlaceLikelihoods().size();
} else {
count = M_MAX_ENTRIES;
}
int i = 0;
mLikelyPlaceNames = new String[count];
mLikelyPlaceAddresses = new String[count];
mLikelyPlaceAttributions = new String[count];
mLikelyPlaceLatLngs = new LatLng[count];
int i = 0;
mLikelyPlaceNames = new String[count];
mLikelyPlaceAddresses = new String[count];
mLikelyPlaceAttributions = new List[count];
mLikelyPlaceLatLngs = new LatLng[count];
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
// Build a list of likely places to show the user.
mLikelyPlaceNames[i] = (String) placeLikelihood.getPlace().getName();
mLikelyPlaceAddresses[i] = (String) placeLikelihood.getPlace()
.getAddress();
mLikelyPlaceAttributions[i] = (String) placeLikelihood.getPlace()
.getAttributions();
mLikelyPlaceLatLngs[i] = placeLikelihood.getPlace().getLatLng();
for (PlaceLikelihood placeLikelihood : likelyPlaces.getPlaceLikelihoods()) {
// Build a list of likely places to show the user.
mLikelyPlaceNames[i] = placeLikelihood.getPlace().getName();
mLikelyPlaceAddresses[i] = placeLikelihood.getPlace().getAddress();
mLikelyPlaceAttributions[i] = placeLikelihood.getPlace()
.getAttributions();
mLikelyPlaceLatLngs[i] = placeLikelihood.getPlace().getLatLng();
i++;
if (i > (count - 1)) {
break;
}
}
// Release the place likelihood buffer, to avoid memory leaks.
likelyPlaces.release();
// Show a dialog offering the user the list of likely places, and add a
// marker at the selected place.
openPlacesDialog();
} else {
Log.e(TAG, "Exception: %s", task.getException());
i++;
if (i > (count - 1)) {
break;
}
}
});
// Show a dialog offering the user the list of likely places, and add a
// marker at the selected place.
MapsActivityCurrentPlace.this.openPlacesDialog();
}
else {
Log.e(TAG, "Exception: %s", task.getException());
}
}
});
} else {
// The user has not granted permission.
Log.i(TAG, "The user did not grant location permission.");

View File

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -15,8 +15,10 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
# Replace the value below with your own Google API key for Android app.
# To learn how to get a Google Maps Platform API key, visit:
# https://developers.google.com/maps/documentation/android-sdk/start#step_4_get_a_google_maps_api_key
# https://developers.google.com/maps/gmp-get-started
GOOGLE_MAPS_API_KEY=YOUR_API_KEY

View File

@ -1,6 +1,6 @@
#Wed Apr 17 15:25:06 PDT 2019
#Mon Dec 30 13:02:57 PST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
compileSdkVersion 29
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.mapwithmarker"
minSdkVersion 15
targetSdkVersion 26
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -22,10 +22,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.google.android.gms:play-services:9.8.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

View File

@ -1,7 +1,7 @@
package com.example.mapwithmarker;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;

View File

@ -16,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

View File

@ -18,5 +18,5 @@ org.gradle.jvmargs=-Xmx1536m
# Replace the value below with your own Google API key for Android app.
# To learn how to get a Google Maps Platform API key, visit:
# https://developers.google.com/maps/documentation/android-sdk/start#step_4_get_a_google_maps_api_key
GOOGLE_MAPS_API_KEY=AIzaSyDqvjPj18uoo4DgyFEey0dCMhV2UQhmkAI
# https://developers.google.com/maps/gmp-get-started
GOOGLE_MAPS_API_KEY=YOUR_API_KEY

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.polygons"
minSdkVersion 15
targetSdkVersion 26
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -20,15 +20,11 @@ android {
}
}
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:25.1.1'
implementation 'com.google.android.gms:play-services-maps:10.2.0'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

View File

@ -1,8 +1,8 @@
package com.example.polygons;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;

View File

@ -16,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

View File

@ -18,5 +18,5 @@ org.gradle.jvmargs=-Xmx1536m
# Replace the value below with your own Google API key for Android app.
# To learn how to get a Google Maps Platform API key, visit:
# https://developers.google.com/maps/documentation/android-sdk/start#step_4_get_a_google_maps_api_key
GOOGLE_MAPS_API_KEY=AIzaSyDqvjPj18uoo4DgyFEey0dCMhV2UQhmkAI
# https://developers.google.com/maps/gmp-get-started
GOOGLE_MAPS_API_KEY=YOUR_API_KEY

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.styledmap"
minSdkVersion 16
targetSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -22,10 +22,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.0.1'
implementation 'com.google.android.gms:play-services:9.8.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

View File

@ -2,8 +2,8 @@ package com.example.styledmap;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;

View File

@ -16,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

View File

@ -18,5 +18,5 @@ org.gradle.jvmargs=-Xmx1536m
# Replace the value below with your own Google API key for Android app.
# To learn how to get a Google Maps Platform API key, visit:
# https://developers.google.com/maps/documentation/android-sdk/start#step_4_get_a_google_maps_api_key
GOOGLE_MAPS_API_KEY=AIzaSyDqvjPj18uoo4DgyFEey0dCMhV2UQhmkAI
# https://developers.google.com/maps/gmp-get-started
GOOGLE_MAPS_API_KEY=YOUR_API_KEY