mapbox / mapbox-plugins-android

Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
https://www.mapbox.com/android-docs/plugins/overview/
BSD 2-Clause "Simplified" License
241 stars 119 forks source link

Location cannot be found with LocationLayer Plugin 5.0 examples #478

Closed AlexeyIke closed 6 years ago

AlexeyIke commented 6 years ago

Hello, I've use Mapbox SDK v6.0.1 and LocationLayer plugin v 0.5.0 I've add location init as described on LocationLayer plugin v 0.5.0 examples: create locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable() and set locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); Location work till GSP available, after GPS off by lost signal or turned off by device settings - no any location found. I've try to set another priority : locationEngine.setPriority(LocationEnginePriority.BALANCED_POWER_ACCURACY);

cammace commented 6 years ago

Could you clarify what Location provider you are using in your app? Sounds like the Google Play Services one which is oftentimes, the most accurate. The LocationEngine is just an abstraction of these Location providers making it easier to switch one out for the other. For Priority settings, I'd recommend reading Google's official documentation on how this works since we change nothing when it comes to this behavior. I can say that both LOST and Google Play Services both use Fused Location information to acquire the best location information. In other words, it will combine, Cellular, WIFI, GPS, and other sensors to try and obtain the most accurate location available.

cc: @electrostat

AlexeyIke commented 6 years ago

You mean i should add 'com.google.android.gms:play-services-location' provider manually into my app? Ok, I thought it supported by location plugin automatically. Therefore, new LocationEngineProvider(this).obtainBestLocationEngineAvailable(). return only ANDROID location engine available.

electrostat commented 6 years ago

@AlexeyIke When using our AndroidLocationEngine, HIGH_ACCURACY does mean that only GPS is used and it will be hard to get a location fix indoors, not near a window. LOW_POWER and BALANCED_POWER_ACCURACY use various degrees of aggression on network (wifi/cell) calls, while NO_POWER is just a passive listener.

The GoogleLocationEngine we offer works similarly, with the added benefit of having wifi integrated into their HIGH_ACCURACY mode.

If you have google play services location enabled within your app we will use the google location engine.

Would you be interested in a non-Google method to get this feature set? We had to drop LOST due to lack of support from their team. If there is enough interest for this kind of feature, we could look into providing that in the future.

sstolz commented 6 years ago

Hi !

Got same kind of issue since I'm using SDK 6.x version (6.1.1) and new com.mapbox.android.core.location.LocationEngine.

I can not manage to get a location when Android system is configured with "Hardware only". I manage to got one when I'm switching to "High precision" (hardware + wifi networks + BT) but the active position on location plugin goes from blue to grey after few seconds.

My Manifest file contains only that permission : <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Gradle info : compileSdkVersion 26, minSdkVersion 18

Device info : Android 6.0.1

onConnected method is well fired but it seems that requestLocationUpdates() method on location engine does not give any results.

@electrostat, I understand that mapbox SDK have kind of HIGH_ACCURACY that use networks and not only GPS hardware. Is it possible that the "hardware only" system parameter can not work with the "new" HIGH_ACCURACY behaviour ? How to make the location engine working in my app if a user select GPS hardware on his system ? I tried NO_POWER but it does not change a thing. JFYI, I was using LOST before and I didn't have this issue.

Regards

electrostat commented 6 years ago

@sstolz Hi, as stated above, we no longer support LOST due to a lack of support on their end.

With a Hardware toggle as you are talking about and a device is indoors, then no our AndroidLocationEngine in HIGH_ACCURACY will not return a location point. It also sounds like that would be the case for the lower levels as well, since the native Android apis rely on software to figure out your location through wifi and network calls. The only way around this would be to utilize Google-Play-Services within your project and use our GoogleLocationEngine. It sounds like you have a unique case though and are looking to avoid this scenario.

Sounds like there is demand for a LOST replacement, so I will look into implementing that and making it an offering within our pipeline.

If you could give me more info on your circumstances and what your app is looking to do, I could make some recommendations to get the desired result you are looking for.

sstolz commented 6 years ago

@electrostat thanks for your answer. My goal is to do geofencing during a mapbox turn-by-turn car navigation session because I need to know when I'm approaching a waypoint on a custom route. I was trying to use LOST geofencing but with the new SDK I switched to Google geofencing. Right now I'm testing geofencing on a mapbox mapview. I will make some tests with the GoogleLocationEngine but I'm not sure to understand what you mean by "your" GoogleLocationEngine. How to know what is the underlying engine used ? Right now I'm already including play-services-location in my project. Do you have any documentation on mapbox location engine ? I didn't find anything on current (v6.1.1) android SDK documentation.

cammace commented 6 years ago

Moving this conversation over to our telem library repo https://github.com/mapbox/mapbox-events-android/issues/141