Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.6k stars 291 forks source link

Geolocation only works if I use React Native Maps with showsUserLocation prop #310

Open Lea23VC opened 2 years ago

Lea23VC commented 2 years ago

The geolocation give bad coords and always give the same ones, they don't update, but if I add the "showsUserLocation" prop to the MapView from React Native Maps, the geolocation service starts to work without any problem.

I don't know what I'm doing wrong, the app has the permissions and I updated the android xml with , , and even

hgvo9 commented 2 years ago

Any news @Lea23VC ? I'm having the same issues as you.

p-ugulino commented 2 years ago

Same problem here

update: managed to solve it by now with @Lea23VC solution

daniele-mc commented 2 years ago

The geolocation give bad coords and always give the same ones, they don't update, but if I add the "showsUserLocation" prop to the MapView from React Native Maps, the geolocation service starts to work without any problem.

I don't know what I'm doing wrong, the app has the permissions and I updated the android xml with , , and even

GOD

hgvo9 commented 2 years ago

Same problem here

update: managed to solve it by now with @Lea23VC solution

Thank you for your answer, I'm afraid I can't see @Lea23VC solution, could you please link it me ?

p-ugulino commented 2 years ago

Same problem here update: managed to solve it by now with @Lea23VC solution

Thank you for your answer, I'm afraid I can't see @Lea23VC solution, could you please link it me ?

Hello! We managed to get it solved adding "showsUserLocation" on the MapView we have.

Lea23VC commented 2 years ago

Hello guys

My problem is that I can't use geolocation without "showsUserLocation", but want to use it without that prop. I want to use a custom marker, not that blue dot

hgvo9 commented 2 years ago

Hello guys

My problem is that I can't use geolocation without "showsUserLocation", but want to use it without that prop. I want to use a custom marker, not that blue dot

Yes indeed, I want to use a custom marker too, weird enough it works on iOS without the prop "showsUserLocation" but on Android it doesn't ...

sdandois commented 2 years ago

I think you are not asking for the ACCESS_FINE_LOCATION permission.

Agontuk commented 2 years ago

Provide a code sample, how are you using this library to get location ?

CDBridger commented 1 year ago

I have the same issue, have both permissions in the manifest but it doesn't actual provide the permissions.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

EDIT:

Seems like you need to prompt the user with

 import { PermissionsAndroid } from 'react-native';

await PermissionsAndroid.requestMultiple([
   'android.permission.ACCESS_COARSE_LOCATION',
   'android.permission.ACCESS_FINE_LOCATION'
 ]);

should probably be added to the setup instructions, or part of the request authorization api call and NOT labelled iOS only.