如何使用基于GPS的Geolocation Plugin getCurrentPostion

时间:2017-12-05 12:47:06

标签: angular ionic-framework

当我使用Geolocation Plugin getCurrentPostion时,它有问题 有时它会根据WIFI获得位置,但我想获得基于GPS的位置(如果有用) 怎么做这个设置? 任何提示都不仅仅是欢迎!



import { Geolocation } from ‘@ionic-native/geolocation’;

…

constructor(private geolocation: Geolocation) {}

…

this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log(‘Error getting location’, error);
});

let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
// data can be a set of coordinates, or an error (if an error occurred).
// data.coords.latitude
// data.coords.longitude
});




1 个答案:

答案 0 :(得分:0)

它在我的方便工作,但最近它开始使用wifi进行当前位置而不是gps。我不知道我对我的方便做了什么。 我将尝试在api上实现高精度以确定它是否有帮助