
[英]@mauron85/cordova-plugin-background-geolocation not working in Ionic 5
[英]Ionic / Cordova geolocation force get position every second
我在 Ionic 项目中使用这个插件。 它是 Angular 版本。
代码如下所示:
getLocation() {
this.geolocation.getCurrentPosition().then((resp) => {
this.lat = resp.coords.latitude
this.lon = resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
this.lat = data.coords.latitude
this.lon = data.coords.longitude
});
}
我需要(如果可能的话)强制 watchPosition 每 1 秒给我一次结果。
这是否可行,或者它是否只在准备就绪时返回 position?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.