【发布时间】:2018-01-31 10:55:28
【问题描述】:
我正在创建一个应用程序,用户(我工作的公司的成员)只需按下按钮并写下名称即可按需注册兴趣点,然后将它们发送并存储到服务器。
但我对位置的准确性有疑问。我正在使用@ionic-native/geolocation,即使我将enableHighAccuracy 设置为true,我收到的位置也不准确。其中一些比拍摄地点更远。
有没有办法仅通过 GPS 传感器获取地理位置?
我已经在谷歌上搜索了几个小时,但没有运气。也许我做错了什么。
这是我在客户端获取位置的代码:
obtenirPosicio(): Promise<Geoposicio> {
return new Promise<Geoposicio>((resolve, reject) => {
const OPCIONS_GPS = {} as GeolocationOptions;
OPCIONS_GPS.enableHighAccuracy = true;
OPCIONS_GPS.maximumAge = 0;
OPCIONS_GPS.timeout = 10000; // 10 segons de timeout per obtenir posicio GPS
this.gps.getCurrentPosition(OPCIONS_GPS).then(res => {
let nova_posicio = {} as Geoposicio;
nova_posicio.lat = res.coords.latitude;
nova_posicio.lng = res.coords.longitude;
resolve(nova_posicio);
}).catch(err => {
reject(err);
});
});
}
PS:我只针对安卓
【问题讨论】:
标签: javascript android ionic-framework gps location