当我将geolocation称为currentlocation时,我面临这样的错误
TypeError: Object(...) is not a function
at Geolocation.getCurrentPosition
import { Geolocation } from '@ionic-native/geolocation/ngx';
constructor(public geolocation:Geolocation ){}
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});
答案 0 :(得分:0)
我试图整理代码,因为我认为代码中存在问题
describe
如果这不起作用,您可以看到此https://forum.ionicframework.com/t/geolocation-issues/157072/7
另外,您可以在此处查看该教程 https://github.com/apache/cordova-plugin-geolocation#coords