Hi everyone. I’ve some problem with cordova-plugin-advanced-geolocation. I try to use them in project but had problem to initialize global variables (she not defined) to use plugin method.
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { DataService } from './tab1/service/data.service';
declare let AdvancedGeolocation: any;
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss']
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private dataService: DataService,
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
if (this.platform.is('android')) {
this.initGeo();
} else {
alert('wrong platform');
}
});
}
initGeo() {
AdvancedGeolocation.start((success) => {
try {
} catch (e) {
console.log(e);
}
},
(err) => {
console.log('ERROR! ' + JSON.stringify(err));
},
////////////////////////////////////////////
//
// REQUIRED:
// These are required Configuration options!
// See API Reference for additional details.
//
////////////////////////////////////////////
{
'minTime':500, // Min time interval between updates (ms)
'minDistance':1, // Min distance between updates (meters)
'noWarn':true, // Native location provider warnings
'providers':'all', // Return GPS, NETWORK and CELL locations
'useCache':true, // Return GPS and NETWORK cached locations
'satelliteData':false, // Return of GPS satellite info
'buffer':false, // Buffer location data
'bufferSize':0, // Max elements in buffer
'signalStrength':false // Return cell signal strength data
});
}
}