2015-11-30 09:54:45 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
2015-12-01 02:34:54 +08:00
|
|
|
declare var Promise;
|
|
|
|
|
2015-11-30 09:54:45 +08:00
|
|
|
declare var window;
|
|
|
|
|
2016-01-26 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get geolocation data.
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```js
|
|
|
|
* Geolocation.getCurrentPosition().then((resp) => {
|
|
|
|
* //resp.coords.latitude
|
|
|
|
* //resp.coords.longitude
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* let watch = Geolocation.watchPosition();
|
2016-02-09 03:06:22 +08:00
|
|
|
* watch.subscribe((data) => {
|
2016-01-26 06:20:36 +08:00
|
|
|
* //data.coords.latitude
|
|
|
|
* //data.coords.longitude
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*/
|
2015-11-30 09:54:45 +08:00
|
|
|
@Plugin({
|
|
|
|
name: 'Geolocation',
|
|
|
|
plugin: 'cordova-plugin-geolocation',
|
|
|
|
pluginRef: 'navigator.geolocation'
|
|
|
|
})
|
2015-12-01 03:27:25 +08:00
|
|
|
export class Geolocation {
|
2015-11-30 09:54:45 +08:00
|
|
|
@Cordova()
|
|
|
|
static getCurrentPosition(options:any){};
|
|
|
|
|
|
|
|
|
2015-12-01 02:34:54 +08:00
|
|
|
@Cordova({
|
2015-12-01 03:27:25 +08:00
|
|
|
callbackOrder: 'reverse',
|
2015-12-01 02:34:54 +08:00
|
|
|
observable: true,
|
2016-02-09 03:06:22 +08:00
|
|
|
clearFunction: 'clearWatch'
|
2015-12-01 02:34:54 +08:00
|
|
|
})
|
|
|
|
static watchPosition(options:any){};
|
2015-11-30 09:54:45 +08:00
|
|
|
}
|