I am getting an error on building my project for ios. This has not occurred after a code change, but after a version change. I just updated to the latest geolocation plugin version, but I do not see any new language specification in the docs related to this method.
The error that I am getting is
typescript: src/providers/location-tracking.ts, line: 32
Argument of type '{ maximumAge: number; timeout: number; enableHighAccuracy: boolean; }' is not assignable
to parameter of type 'PositionCallback'. Type '{ maximumAge: number; timeout: number; enableHighAccuracy:
boolean; }' provides no match for the signature '(position: Position): void'.
L31: return Observable.create(observer => {
L32: this.watch = this.geolocation.watchPosition(options)
L33: .filter((p: any) => p.code === undefined).subscribe(pos => {
Error: Failed to transpile program
at new BuildError (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at transpileWorker (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/build.js:106:82
Here is all the code that is responsible for getting the geolocation data:
constructor(public zone: NgZone, private geolocation: Geolocation, public http: Http) {
console.log('Hello LocationTracking Provider');
}
startTracking() {
let options = {
maximumAge: 3000,
timeout: 5000,
enableHighAccuracy: true
}
return Observable.create(observer => {
this.watch = this.geolocation.watchPosition(options)
.filter((p: any) => p.code === undefined).subscribe(pos => {
this.zone.run(() => {
this.lat = pos.coords.latitude;
this.lng = pos.coords.longitude;
this.time = pos.coords.timestamp;
this.getZip().subscribe(data => {
observer.next(JSON.parse(data));
});
})
})
});
}
Please let me know how I can fix this or restructure my code. Thank you.