我正在使用navigator.geolocation.watchPosition和getCurrentPosition实现健身跟踪器.它在Android和ios仿真器上工作正常,准确度为5/10m,但在iphone 5s上,我的准确度很差(50/65).
我发现当我在ios上同时运行现有的健身追踪器(strava)时,突然我的应用程序正在非常精确地检索GPS坐标.
很明显我必须缺少一些配置,因为默认情况下我的应用程序在iOS上使用不高.知道如何解决这个问题吗?
码:
const GPS_TIMEOUT_GET = 5000;
const GPS_MAX_AGE = 1000;
const GPS_DISTANCE_FILTER = 5;
const GPS_TIMEOUT_WATCH = 60000;
const GPS_MIN_ACCURACY = 50;
//start the GPS into full time watching. Drains battery but brings best accuracy (required for our needs)
let watchId = navigator.geolocation.watchPosition((position) => {
}
, (error) => {
console.log(error);
}
, {
enableHighAccuracy: true,
timeout: GPS_TIMEOUT_WATCH,
maximumAge: GPS_MAX_AGE,
distanceFilter: GPS_DISTANCE_FILTER
});
//check GPS every X milliseconds)
let intervalId = BackgroundTimer.setInterval(() => {
navigator.geolocation.getCurrentPosition((geoPosition) => { …Run Code Online (Sandbox Code Playgroud)