Open vvscode opened 4 years ago
Try to use:
enableHighAccuracy: false
=(
Try to use:
enableHighAccuracy: false
=(
That sometimes works, I solved by changing the library https://github.com/react-native-community/react-native-geolocation/issues/43#issuecomment-573443763. I tested in a few devices and everything seems working fine but I haven't tested in production. When I have more information I will let you know
For me i found that removing the maximumAge
solves the timeout issue
It works by removing enableHighAcurracy
and maximumAge
It's an issue has been here for a long time. It's a serious issue for basic usage of the lib. getCurrentPosition
has been used in +90% of the cases and it doesn't work properly on Android.
work for me
Geolocation.getCurrentPosition((success)=>{console.log(success)}, (e)=>{console.log(e)}, {timeout: 20000});
Try to use:
enableHighAccuracy: false
=(
Worked for me!
const getUserCurrentLocation = () => {
let latitude, longitude
Geocoder.init(google_api_key)
Geolocation.getCurrentPosition(
info => {
const { coords } = info
latitude = coords.latitude
longitude = coords.longitude
setLat(latitude)
setLng(longitude)
getUserCurrentAddress(latitude, longitude)
},
error => console.log(error),
{
enableHighAccuracy: false,
timeout: 2000,
maximumAge: 3600000
}
)
}
NOTE: Attention to the order of the parameters passed to the function "Geolocation.getCurrentPosition"! They must be in that order: success function, error function and parameters.
Try it out:
useEffect(()=>{ setTimeOut(() => { getCurrentPosition() },1000) },[])
The main problem is, if you turn off enableHighAccuracy, position determination by geolocation is downgrading. I met this problem several times, and always had a problem
Same issue... In this post I read that this issue occurs depending on Android SDK version. Can anyone tell me if this is true? If so the lib should mention so in the docs, right?
I tested it on an AVD simulator with SDK 29 and it worked fine... But when I test on a real device with android 8.1.0 this doesn't work and my request times out..
Removing the [maximumAge] doesn't solve it for me and setting [enableHighAccuracy] to false is a no-op for me.
I have tried many ways to fix this issue and non of them properly worked. It works on most of devices but in some cases its not even work on them and the error is always location request timed out
. This is a serious bug and there is no proper error information, plus no permission
or Google Play Services
check in Android devices.
I am going to take a chance and try this library as its created based on this issue.
UPDATE: I am writing this after almost 2 years of this comment and received no issue after using react-native-geolocation-service
.
Hi, @joaovitorzv Thank you. Among solutions above, yours solved my problem. you are amazing!
Hi, @joaovitorzv Thank you. Among solutions above, yours solved my problem. you are amazing!
Just to mention, the suggestion given by @joaovitorzv is not a solution but a workaround for not using HighAccuracy of GPS location.
, error => console.log(error), { enableHighAccuracy: false, timeout: 2000, maximumAge: 3600000 }
jazakALLAH dudes this helps me to solve the above error happy coding :)
Thanks so much, I appreciate
On Fri, Jul 2, 2021 at 1:12 PM rajAmukhliS @.***> wrote:
, error => console.log(error), { enableHighAccuracy: false, timeout: 2000, maximumAge: 3600000 }
jazakALLAH dudes this helps me to solve the above error happy coding :)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/react-native-geolocation/react-native-geolocation/issues/90#issuecomment-872719476, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALQOYD5HX4X3IEI2OPLBE73TVVDDDANCNFSM4KHQ6O7Q .
It seems to @react-native-community/geolocation not work properly.
You can follow this issue (on the official GitHub page) to receive a future answer.
But for now, you can use react-native-geolocation-service without any problems.
import Geolocation from 'react-native-geolocation-service'; ...
componentDidMount() { if (hasLocationPermission) { Geolocation.getCurrentPosition( (position) => { console.log(position); }, (error) => { // See error code charts below. console.log(error.code, error.message); }, { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 } ); } } https://github.com/Agontuk/react-native-geolocation-service
Thanks
On Mon, Oct 4, 2021 at 1:48 PM Jorge Jhovani Valverde León < @.***> wrote:
It seems to @react-native-community/geolocation not work properly.
You can follow this issue (on the official GitHub page) to receive a future answer.
But for now, you can use react-native-geolocation-service without any problems.
import Geolocation from 'react-native-geolocation-service'; ...
componentDidMount() { if (hasLocationPermission) { Geolocation.getCurrentPosition( (position) => { console.log(position); }, (error) => { // See error code charts below. console.log(error.code, error.message); }, { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 } ); } } https://github.com/Agontuk/react-native-geolocation-service
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/react-native-geolocation/react-native-geolocation/issues/90#issuecomment-933161863, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALQOYDZV5ECGLRZMN6CNS3TUFE5ZPANCNFSM4KHQ6O7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Increasing the timeout time worked for me guys!
All solutions above didn't work for me, so i tried just setting enableHighAccuracy
as true.
I got some references from this doc: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
This worked for me too! Thanks mate @danielcnascimento
It works by removing
enableHighAcurracy
andmaximumAge
This works, confirmed. Thank You
so guys its not the issue of codding or appllication its the isssue of mobile i have the same poblem but after changing my mobile everything is worked correctly
{
// enableHighAccuracy: false,
timeout: 15000,
// maximumAge: 10000,
},
Environment
Platforms
Android
Versions
Description
I use code
and it gives me
I checked settings - location services is on, permissions provided (plus other package
react-native-background-geolocation
) get's location fine