Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 爱奥尼亚3:背景位置更新太少了_Ionic Framework_Ionic2_Ionic3 - Fatal编程技术网

Ionic framework 爱奥尼亚3:背景位置更新太少了

Ionic framework 爱奥尼亚3:背景位置更新太少了,ionic-framework,ionic2,ionic3,Ionic Framework,Ionic2,Ionic3,我现在面临一个不太好的问题。我已经创建了一个问题,但没有响应。我需要每次位置更改来更新相机中心位置。但这并没有发生。刷新不可随时间定义。这对我来说是非常罕见的。Android和iOS是一样的。日志被称为每分钟或类似的东西。 我还尝试了ngZone之外的控制台日志,但结果是一样的。 以下是我的配置代码: let config = { desiredAccuracy: 0, stationaryRadius: 1, distanceFilter: 0, debug: true,

我现在面临一个不太好的问题。我已经创建了一个问题,但没有响应。我需要每次位置更改来更新相机中心位置。但这并没有发生。刷新不可随时间定义。这对我来说是非常罕见的。Android和iOS是一样的。日志被称为每分钟或类似的东西。 我还尝试了
ngZone
之外的控制台日志,但结果是一样的。 以下是我的配置代码:

let config = {
  desiredAccuracy: 0,
  stationaryRadius: 1,
  distanceFilter: 0,
  debug: true,
  interval: 2000,
  pauseLocationUpdates: false,
  activityType: "AutomotiveNavigation"
};

this.backgroundGeolocation.configure(config).subscribe((location) => {
  // Run update inside of Angular's zone
  this.zone.run(() => {
    if(this.map) {
      this.map.getMyLocation().then( (userLocation: MyLocation) => {
        console.log("INSIDE ZONE Google Maps Location \n LAT: " + userLocation.latLng.lat + "\nLNG: " + userLocation.latLng.lng);
        this.userLocation = userLocation.latLng;
        this.speed = userLocation.speed;
        this.bearing = userLocation.bearing;
        this.altitude = location.altitude;

        this.cameraFollow();
        this.notify(this.nearestReports[0]);
      }).catch( error => {
        alert("Background - NO GPS FOUND: " + error);
      });
    }
  });
});

// Turn ON the background-geolocation system.
this.backgroundGeolocation.start();

考虑使用另一个名为Ionic的本机插件

其中有一个非常方便的
watchPosition()
函数,看起来就像您正在寻找的一样。下面是一个例子:

let选项={
EnableHighAccurance:正确,
timeout:Infinity,//在操作系统提供新的ping之前不要返回响应,以节省电池
最大值:0
};
const subscription=this.geolocation.watchPosition(选项)
.filter((p)=>p.coords!==未定义)//筛选出错误
.订阅(职位=>{
console.log(position.coords.longitude+''+position.coords.lation);
});
不要忘记在不需要时停止订阅以节省电池:

subscription.unsubscribe();

考虑使用另一个名为Ionic的本机插件

其中有一个非常方便的
watchPosition()
函数,看起来就像您正在寻找的一样。下面是一个例子:

let选项={
EnableHighAccurance:正确,
timeout:Infinity,//在操作系统提供新的ping之前不要返回响应,以节省电池
最大值:0
};
const subscription=this.geolocation.watchPosition(选项)
.filter((p)=>p.coords!==未定义)//筛选出错误
.订阅(职位=>{
console.log(position.coords.longitude+''+position.coords.lation);
});
不要忘记在不需要时停止订阅以节省电池:

subscription.unsubscribe();

但是这个插件不适用于后台位置,不是吗?老实说,我不确定。我检查了一下(您使用的插件取决于),它显示
位置更新之间的间隔时间永远不会小于minTime,尽管它可能更多地取决于位置提供程序的实现和其他应用程序请求的更新间隔。所以在后台真的没有办法最小化它。我希望这已经回答了你的问题。但是这个插件不适用于后台位置,不是吗?老实说,我不确定。我检查了一下(您使用的插件取决于),它显示
位置更新之间的间隔时间永远不会小于minTime,尽管它可能更多地取决于位置提供程序的实现和其他应用程序请求的更新间隔。因此,在背景中确实没有办法将其最小化。我希望这已经回答了你的问题。