I am trying to test the geolocation feature of ionic, as described in the documentation here: https://ionicframework.com/docs/v2/native/geolocation/
This is on
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v7.7.3
Xcode version: Not installed
When trying the simplest example in this documentation,
Geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});
compilation within “ionic serve” fails with
[14:47:26] typescript: src/app/app.component.ts, line: 23
Property 'getCurrentPosition' does not exist on type 'typeof Geolocation'.
L23: Geolocation.getCurrentPosition().then((resp) => {
L24: // resp.coords.latitude
[14:47:26] transpile failed
I tried to narrow it down by creating a simple ionic application from scratch as test case, but this fails too.
Code is available at: https://github.com/ajeans/ionic2-geolocation
Am I doing something obviously wrong here?
Thanks.