mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 16:52:53 +08:00
parent
a15fb01a54
commit
4a8650e45e
@ -1,7 +1,7 @@
|
|||||||
import {Plugin, Cordova} from './plugin';
|
import {Plugin, Cordova} from './plugin';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
|
||||||
declare var window;
|
declare var navigator: any;
|
||||||
|
|
||||||
export interface Coordinates {
|
export interface Coordinates {
|
||||||
/**
|
/**
|
||||||
@ -151,10 +151,13 @@ export class Geolocation {
|
|||||||
* @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
* @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
||||||
* @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors.
|
* @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
static watchPosition(options?: GeolocationOptions): Observable<Geoposition> {
|
||||||
callbackOrder: 'reverse',
|
return new Observable<Geoposition>(
|
||||||
observable: true,
|
(observer: any) => {
|
||||||
clearFunction: 'clearWatch'
|
let cb = (data: Geoposition) => observer.next(data);
|
||||||
})
|
let watchId = navigator.geolocation.watchPosition(cb, options);
|
||||||
static watchPosition(options?: GeolocationOptions): Observable<Geoposition> { return; }
|
return () => navigator.geolocation.clearWatch(watchId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user