Skip to content

Improved user location on Android#2993

Merged
christopherdro merged 15 commits intoreact-native-maps:masterfrom
funkyfourier:locationsource
Feb 8, 2020
Merged

Improved user location on Android#2993
christopherdro merged 15 commits intoreact-native-maps:masterfrom
funkyfourier:locationsource

Conversation

@funkyfourier
Copy link
Copy Markdown
Contributor

Does any other open PR do the same thing?

Not that I can see.

What issue is this PR fixing?

#2923

Also, it brings some new possibilities for controlling power consumption and accuracy of user location in maps, specifically userLocationPriority, userLocationUpdateInterval and userLocationFastestInterval. This is achieved by setting a custom LocationSource on the GoogleMap object, which exposes these properties and does not cause issue #2923.

How did you test this PR?

This PR applies only to Android. I have described in the issue mention above how to recreate the issue, and this PR solves it. It has been tested on a OnePlus 6 and a Sony XZ1.

Copy link
Copy Markdown
Contributor

@felipecsl felipecsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good with some minor nits

Comment thread lib/android/build.gradle Outdated
exclude group: 'com.android.support'
}
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.google.android.gms:play-services-location:16.0.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be using the same ${safeExtGet('playServicesVersion', '16.1.0') mechanism?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I discovered that play-services-location does not exactly follow the same versions as the rest of Play Services.

For example, play-services-location does not have a version 16.1.0:
https://mvnrepository.com/artifact/com.google.android.gms/play-services-maps

But for example play-services-maps does:
https://mvnrepository.com/artifact/com.google.android.gms/play-services-maps

Or am I missing something? If not, there are two ways to do it:

  1. Use a constant hard coded version like I did.
  2. Expose another Gradle variable like "locationServicesVersion" or something like that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I looked directly in the Google maven repo too and it doesnt seem to have version 16.1.0 for play-services-location. That's confusing!
Thanks for explaining, this seems reasonable then!

Comment thread lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java Outdated
import com.google.android.gms.maps.LocationSource;
import com.google.android.gms.tasks.OnSuccessListener;

public class FusedLocationSource implements LocationSource {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record:
This file is indented with 4 spaces while the rest of the project is indented with 2 spaces.
It's non blocking, we should create a separate pull request for automatic style checking/formatting.

@christopherdro
Copy link
Copy Markdown
Collaborator

@funkyfourier Could you resolve the conflicts when you get a chance? Here are the changes that cause the conflict. 801614e#diff-ac45350dc94234f6d3c8b856aacbc395

@funkyfourier
Copy link
Copy Markdown
Contributor Author

Was the fixes ok? When will this be merged?

Thank you.

@christopherdro christopherdro merged commit bf03246 into react-native-maps:master Feb 8, 2020
@christopherdro
Copy link
Copy Markdown
Collaborator

@funkyfourier Any thoughts on the issue linked to this PR?

@funkyfourier
Copy link
Copy Markdown
Contributor Author

I'll have a look tomorrow.

@funkyfourier funkyfourier deleted the locationsource branch March 6, 2020 09:12
pinpong pushed a commit to pinpong/react-native-maps that referenced this pull request Feb 28, 2025
* Use custom made LocationSource

* Added property to set priority for user location

* Property for setting priority of user location

* Property for update interval of user location

* Changed default update interval for user location to 5000 ms

* Property for setting fastest interval for user location updates

* Updated documentation

* Fixed documentation update

* Fixed documentation update

* Fixed documentation update

* Fixed documentation update

* Fixed documentation update

* Set fields to final where possible

* Merged changes for AndroidX

Co-authored-by: jmrhvl <45755981+jmrhvl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants