如何在任何时候(例如5、10或20分钟)在后台存储GPS位置并将其存储到localStorage中?谢谢
答案 0 :(得分:0)
像这样编辑
public geolocate() {
var options = {
enableHighAccuracy: false,
maximumAge: Infinity
};
this.geo.getCurrentPosition(options)
.then((resp) => {
console.log("What is in this geolocate? ", resp);
const location = { Lat: resp.coords.latitude, Lon: resp.coords.longitude };
this.storage.set('GeoLocation', location);
})
.catch((error) => {
console.log('Error getting location', error);
});
}
现在按如下所示的setinterval调用此函数
setInterval(() => {
this.geolocate();
}, 600);
以便您的函数每600毫秒调用一次,并执行插件和存储操作。