2017-06-07 1 views
1

現在、問題はあまり良くありません。私はすでに問題を作成しましたが、回答はありません。私は、カメラの中心位置を更新するために、あらゆる場所の変更が必要です。しかし、これは起こりません。リフレッシュは時間とともに定義できません。それは私の必要性のために非常にまれです。 AndroidとiOSは同じです。ログは1分ごとに呼び出されます。 また、ngZoneの外部にあるコンソールログを試しましたが、それは同じです。 これは私の構成コードは次のようになります。Ionic 3:BackgroundLocationの更新があまりにも珍しい

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(); 

答えて

0

Geolocationと呼ばれる別のイオンのネイティブプラグインを使用することを検討してください。

あなたの探しているもののように見える非常に便利なwatchPosition()機能があります。ここでは例です:

let options = { 
    enableHighAccuracy: true, 
    timeout: Infinity, // don't return response until new ping is available from OS, to save battery 
    maximumAge: 0 
}; 

const subscription = this.geolocation.watchPosition(options) 
    .filter((p) => p.coords !== undefined) //Filter Out Errors 
    .subscribe(position => { 
     console.log(position.coords.longitude + ' ' + position.coords.latitude); 
}); 

は、バッテリーを節約するために必要でないときは、サブスクリプションを停止することを忘れないでください:

subscription.unsubscribe(); 
+0

しかし、このプラグインは、バックグラウンドの場所のために働いていないそうではありませんか? – TdoubleG

+0

私は正直には分かりません。私は[アンドロイドがバックグラウンドロケーションサービスをどのように処理するか]を確認しました(https://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long、%20float、%20andandroid.location.Criteria、%20android.app .PendingIntent)))ただし、Location Pluginが使用するプラグインは依存しています。Location Updateの経過時間は、Location Providerの実装と他のアプリケーションから要求された更新間隔によりますが、minTimeより小さくなることはありません'。したがって、実際にはバックグラウンドで最小化する方法はありません。 – maninak

+0

私はこれがあなたの質問に答えたことを願っています。 – maninak

関連する問題