diff --git a/lib/android/build.gradle b/lib/android/build.gradle index 3995544f98..893ff2c309 100644 --- a/lib/android/build.gradle +++ b/lib/android/build.gradle @@ -24,7 +24,8 @@ dependencies { implementation('com.facebook.react:react-native:+') { exclude group: 'com.android.support' } - implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '16.1.0')}" - implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '16.1.0')}" + implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '17.0.0')}" + implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '17.0.0')}" + implementation "com.google.android.gms:play-services-location:17.0.0" implementation 'com.google.maps.android:android-maps-utils:0.5' } diff --git a/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java b/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java index 332d60f554..424eb149e0 100644 --- a/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +++ b/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java @@ -112,6 +112,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter, private boolean destroyed = false; private final ThemedReactContext context; private final EventDispatcher eventDispatcher; + private FusedLocationSource fusedLocationSource; private ViewAttacherGroup attacherGroup; @@ -161,6 +162,8 @@ public AirMapView(ThemedReactContext reactContext, ReactApplicationContext appCo final AirMapView view = this; + fusedLocationSource = new FusedLocationSource(context); + gestureDetector = new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGestureListener() { @@ -385,6 +388,7 @@ public void onHostResume() { if (hasPermissions()) { //noinspection MissingPermission map.setMyLocationEnabled(showUserLocation); + map.setLocationSource(fusedLocationSource); } synchronized (AirMapView.this) { if (!destroyed) { @@ -513,11 +517,24 @@ public void setCamera(ReadableMap camera) { public void setShowsUserLocation(boolean showUserLocation) { this.showUserLocation = showUserLocation; // hold onto this for lifecycle handling if (hasPermissions()) { + map.setLocationSource(fusedLocationSource); //noinspection MissingPermission map.setMyLocationEnabled(showUserLocation); } } + public void setUserLocationPriority(int priority){ + fusedLocationSource.setPriority(priority); + } + + public void setUserLocationUpdateInterval(int interval){ + fusedLocationSource.setInterval(interval); + } + + public void setUserLocationFastestInterval(int interval){ + fusedLocationSource.setFastestInterval(interval); + } + public void setShowsMyLocationButton(boolean showMyLocationButton) { if (hasPermissions() || !showMyLocationButton) { map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);