Background Location update to rare


#1

Hello,

I’m currently facing a problem that is not so nice. I need every location change to update the camera center position. But this doesn’t happen. The refresh is not definable with time. It’s just very rare for my needs. Android and iOS is the same. The log is called every minute or something like that.
Also I tried the console log outside the ngZone but it’s the same.
This is what my configuration code looks like:

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


#2

Hi there…

is your code still have an error ??


#3

Hey,

I’m using the Geolocation Plugin and the Background Geolocation. The Geolocation Plugin for the foreground geolocation:

 let options = {
      frequency: 3000,
      enableHighAccuracy: true
    };

    this.foregroundWatch = this.geolocation.watchPosition(options)
      .filter((p: any) => p.code === undefined)
      .subscribe((position: Geoposition) => {
        this.zone.run(() => {
          //console.log("Foreground Geolocation");
          this.userLocation = new LatLng(position.coords.latitude,position.coords.longitude);
          this.speed = position.coords.speed;
          this.bearing = position.coords.heading ? position.coords.heading : 0;
          this.altitude = position.coords.altitude;
          this.cameraFollow();

          this.handlePush();

        });
    });