awesome-cordova-plugins/src/plugins/geolocation.ts

42 lines
744 B
TypeScript
Raw Normal View History

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;
/**
* Get geolocation data.
*
* @usage
* ```js
* Geolocation.getCurrentPosition().then((resp) => {
* //resp.coords.latitude
* //resp.coords.longitude
* })
*
* let watch = Geolocation.watchPosition();
* watch.subscribe((data) => {
* //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,
clearFunction: 'clearWatch'
2015-12-01 02:34:54 +08:00
})
static watchPosition(options:any){};
2015-11-30 09:54:45 +08:00
}