NativeScript / nativescript-geolocation

Geolocation plugin to use for getting current location, monitor movement, etc
Apache License 2.0
139 stars 77 forks source link

TypeError: Cannot read property 'Accuracy' of undefined. #280

Open nicolaric opened 3 years ago

nicolaric commented 3 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Hey guys, calling await geolocation.enableLocationRequest(); throws following error: Error: Cannot enable the location service. TypeError: Cannot read property 'Accuracy' of undefined. I tried several things, including the part on nativescript doc (https://docs.nativescript.org/plugins/geolocation.html#known-issues) , which tells you to add googlePlayServicesVersion = "16.+" to the before-plugins.gradle file. In the end, I dived into the code of the package. I found out, that the Enums import somehow isn't defined.(it also is deprecated, but has nothing to do with that). The Accuracy attribute is not even available in the namespace. I tried it on several PC's and always got the same error (could it be, that I use @nativescript-community/ui-mapbox as well, which uses the users location?). Thanks a lot for helping!

Is there any code involved?

`import * as geolocation from '@nativescript/geolocation'; ... ngOnInit() { await geolocation.enableLocationRequest(); // console.log(await geolocation.isEnabled());

const location = await geolocation.getCurrentLocation({
  desiredAccuracy: CoreTypes.Accuracy.high,
  maximumAge: 5000,
  timeout: 20000,
});

}`

OPADA-Eng commented 2 years ago

try yo update core version to the latest one "@nativescript/core": "8.1.3",