Trying to use the following to get the users current lat/lng but getting location unavailable
const { Geolocation } = Plugins;
await Geolocation.requestPermissions();
const geoTest = await Geolocation.getCurrentPosition({timeout: 30000, enableHighAccuracy: true})
console.log('Current' + JSON.stringify(geoTest) );
Error output from the AVD
D/Capacitor: Sending plugin error: {"save":false,"callbackId":"110022566","pluginId":"Geolocation","methodName":"getCurrentPosition","success":false,"error":{"message":"location unavailable"}}
Capacitor Doctor
馃拪 Capacitor Doctor 馃拪
Latest Dependencies:
@capacitor/cli: 1.3.0
@capacitor/core: 1.3.0
@capacitor/android: 1.3.0
@capacitor/ios: 1.3.0
Installed Dependencies:
@capacitor/cli 1.3.0
@capacitor/core 1.3.0
@capacitor/android 1.3.0
@capacitor/ios 1.3.0
[success] Android looking great! 馃憣
Found 16 Capacitor plugins for ios:
android-camera-permission (1.0.0)
com-sarriaroman-photoviewer (1.2.4)
cordova-plugin-actionsheet (2.3.3)
cordova-plugin-advanced-http (2.2.0)
cordova-plugin-app-version (0.1.9)
cordova-plugin-camera (4.1.0)
cordova-plugin-dialogs (2.0.2)
cordova-plugin-facebook4 (6.2.0)
cordova-plugin-file (6.0.2)
cordova-plugin-geolocation (4.0.2)
cordova-plugin-market (1.2.0)
cordova-plugin-request-location-accuracy (2.3.0)
cordova-plugin-screen-orientation (3.0.2)
cordova-sqlite-storage (3.4.0)
es6-promise-plugin (4.2.2)
uk.co.workingedge.phonegap.plugin.launchnavigator (5.0.4)
[success] iOS looking great! 馃憣
How do I get the users current lat and lng with this plugin ?
That's by design of the Android SDK API we use, it returns last known location without trying to get one. If you want to get real location better use watchPosition.
There is a PR to use Fused Location Provider #964
@jcesarmobile what do you mean by PR please