Renamed prefixes in angular.json
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma
2019-11-04 13:43:46 +01:00
parent c32214f544
commit cec43a636c
183 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
import { Injectable } from '@angular/core';
import { Observer, Observable } from 'rxjs';
/**
* GeolocationService class.
* https://developers.google.com/maps/documentation/javascript/
* https://dev.w3.org/geo/api/spec-source.html
*/
@Injectable()
export class GeolocationService {
/**
* Tries HTML5 geolocation.
*
* Wraps the Geolocation API into an observable.
*
* @return An observable of Position
*/
getCurrentPosition(): Observable<Position> {
return Observable.create((observer: Observer<Position>) => {
// Invokes getCurrentPosition method of Geolocation API.
navigator.geolocation.watchPosition(
(position: Position) => {
observer.next(position);
observer.complete();
},
(error: PositionError) => {
console.log('Geolocation service: ' + error.message);
observer.error(error);
},
{
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
}
);
});
}
}