|
@@ -0,0 +1,224 @@
|
|
1
|
+var __extends = (this && this.__extends) || (function () {
|
|
2
|
+ var extendStatics = Object.setPrototypeOf ||
|
|
3
|
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4
|
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
5
|
+ return function (d, b) {
|
|
6
|
+ extendStatics(d, b);
|
|
7
|
+ function __() { this.constructor = d; }
|
|
8
|
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
9
|
+ };
|
|
10
|
+})();
|
|
11
|
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+};
|
|
17
|
+var __metadata = (this && this.__metadata) || function (k, v) {
|
|
18
|
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
19
|
+};
|
|
20
|
+import { Injectable } from '@angular/core';
|
|
21
|
+import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
|
|
22
|
+import { Observable } from 'rxjs/Observable';
|
|
23
|
+/**
|
|
24
|
+ * @name Geolocation
|
|
25
|
+ * @description
|
|
26
|
+ * This plugin provides information about the device's location, such as latitude and longitude. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs.
|
|
27
|
+ *
|
|
28
|
+ * This API is based on the W3C Geolocation API Specification, and only executes on devices that don't already provide an implementation.
|
|
29
|
+ *
|
|
30
|
+ * For iOS you have to add this configuration to your configuration.xml file
|
|
31
|
+ * ```xml
|
|
32
|
+ * <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
|
|
33
|
+ * <string>We want your location! Best regards NSA</string>
|
|
34
|
+ * </edit-config>
|
|
35
|
+ * ```
|
|
36
|
+ *
|
|
37
|
+ *
|
|
38
|
+ * @usage
|
|
39
|
+ *
|
|
40
|
+ * ```typescript
|
|
41
|
+ * import { Geolocation } from '@ionic-native/geolocation';
|
|
42
|
+ *
|
|
43
|
+ * ...
|
|
44
|
+ *
|
|
45
|
+ * constructor(private geolocation: Geolocation) {}
|
|
46
|
+ *
|
|
47
|
+ * ...
|
|
48
|
+ *
|
|
49
|
+ * this.geolocation.getCurrentPosition().then((resp) => {
|
|
50
|
+ * // resp.coords.latitude
|
|
51
|
+ * // resp.coords.longitude
|
|
52
|
+ * }).catch((error) => {
|
|
53
|
+ * console.log('Error getting location', error);
|
|
54
|
+ * });
|
|
55
|
+ *
|
|
56
|
+ * let watch = this.geolocation.watchPosition();
|
|
57
|
+ * watch.subscribe((data) => {
|
|
58
|
+ * // data can be a set of coordinates, or an error (if an error occurred).
|
|
59
|
+ * // data.coords.latitude
|
|
60
|
+ * // data.coords.longitude
|
|
61
|
+ * });
|
|
62
|
+ * ```
|
|
63
|
+ * @interfaces
|
|
64
|
+ * Coordinates
|
|
65
|
+ * Geoposition
|
|
66
|
+ * PositionError
|
|
67
|
+ * GeolocationOptions
|
|
68
|
+ */
|
|
69
|
+var Geolocation = (function (_super) {
|
|
70
|
+ __extends(Geolocation, _super);
|
|
71
|
+ function Geolocation() {
|
|
72
|
+ return _super !== null && _super.apply(this, arguments) || this;
|
|
73
|
+ }
|
|
74
|
+ /**
|
|
75
|
+ * Get the device's current position.
|
|
76
|
+ *
|
|
77
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
78
|
+ * @returns {Promise<Geoposition>} Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error.
|
|
79
|
+ */
|
|
80
|
+ /**
|
|
81
|
+ * Get the device's current position.
|
|
82
|
+ *
|
|
83
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
84
|
+ * @returns {Promise<Geoposition>} Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error.
|
|
85
|
+ */
|
|
86
|
+ Geolocation.prototype.getCurrentPosition = /**
|
|
87
|
+ * Get the device's current position.
|
|
88
|
+ *
|
|
89
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
90
|
+ * @returns {Promise<Geoposition>} Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error.
|
|
91
|
+ */
|
|
92
|
+ function (options) { return; };
|
|
93
|
+ /**
|
|
94
|
+ * Watch the current device's position. Clear the watch by unsubscribing from
|
|
95
|
+ * Observable changes.
|
|
96
|
+ *
|
|
97
|
+ * ```typescript
|
|
98
|
+ * const subscription = this.geolocation.watchPosition()
|
|
99
|
+ * .filter((p) => p.coords !== undefined) //Filter Out Errors
|
|
100
|
+ * .subscribe(position => {
|
|
101
|
+ * console.log(position.coords.longitude + ' ' + position.coords.latitude);
|
|
102
|
+ * });
|
|
103
|
+ *
|
|
104
|
+ * // To stop notifications
|
|
105
|
+ * subscription.unsubscribe();
|
|
106
|
+ * ```
|
|
107
|
+ *
|
|
108
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
109
|
+ * @returns {Observable<Geoposition>} Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors.
|
|
110
|
+ */
|
|
111
|
+ /**
|
|
112
|
+ * Watch the current device's position. Clear the watch by unsubscribing from
|
|
113
|
+ * Observable changes.
|
|
114
|
+ *
|
|
115
|
+ * ```typescript
|
|
116
|
+ * const subscription = this.geolocation.watchPosition()
|
|
117
|
+ * .filter((p) => p.coords !== undefined) //Filter Out Errors
|
|
118
|
+ * .subscribe(position => {
|
|
119
|
+ * console.log(position.coords.longitude + ' ' + position.coords.latitude);
|
|
120
|
+ * });
|
|
121
|
+ *
|
|
122
|
+ * // To stop notifications
|
|
123
|
+ * subscription.unsubscribe();
|
|
124
|
+ * ```
|
|
125
|
+ *
|
|
126
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
127
|
+ * @returns {Observable<Geoposition>} Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors.
|
|
128
|
+ */
|
|
129
|
+ Geolocation.prototype.watchPosition = /**
|
|
130
|
+ * Watch the current device's position. Clear the watch by unsubscribing from
|
|
131
|
+ * Observable changes.
|
|
132
|
+ *
|
|
133
|
+ * ```typescript
|
|
134
|
+ * const subscription = this.geolocation.watchPosition()
|
|
135
|
+ * .filter((p) => p.coords !== undefined) //Filter Out Errors
|
|
136
|
+ * .subscribe(position => {
|
|
137
|
+ * console.log(position.coords.longitude + ' ' + position.coords.latitude);
|
|
138
|
+ * });
|
|
139
|
+ *
|
|
140
|
+ * // To stop notifications
|
|
141
|
+ * subscription.unsubscribe();
|
|
142
|
+ * ```
|
|
143
|
+ *
|
|
144
|
+ * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
|
|
145
|
+ * @returns {Observable<Geoposition>} Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors.
|
|
146
|
+ */
|
|
147
|
+ function (options) {
|
|
148
|
+ return new Observable(function (observer) {
|
|
149
|
+ var watchId = navigator.geolocation.watchPosition(observer.next.bind(observer), observer.next.bind(observer), options);
|
|
150
|
+ return function () { return navigator.geolocation.clearWatch(watchId); };
|
|
151
|
+ });
|
|
152
|
+ };
|
|
153
|
+ Geolocation.decorators = [
|
|
154
|
+ { type: Injectable },
|
|
155
|
+ ];
|
|
156
|
+ __decorate([
|
|
157
|
+ Cordova({
|
|
158
|
+ callbackOrder: 'reverse'
|
|
159
|
+ }),
|
|
160
|
+ __metadata("design:type", Function),
|
|
161
|
+ __metadata("design:paramtypes", [Object]),
|
|
162
|
+ __metadata("design:returntype", Promise)
|
|
163
|
+ ], Geolocation.prototype, "getCurrentPosition", null);
|
|
164
|
+ /**
|
|
165
|
+ * @name Geolocation
|
|
166
|
+ * @description
|
|
167
|
+ * This plugin provides information about the device's location, such as latitude and longitude. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs.
|
|
168
|
+ *
|
|
169
|
+ * This API is based on the W3C Geolocation API Specification, and only executes on devices that don't already provide an implementation.
|
|
170
|
+ *
|
|
171
|
+ * For iOS you have to add this configuration to your configuration.xml file
|
|
172
|
+ * ```xml
|
|
173
|
+ * <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
|
|
174
|
+ * <string>We want your location! Best regards NSA</string>
|
|
175
|
+ * </edit-config>
|
|
176
|
+ * ```
|
|
177
|
+ *
|
|
178
|
+ *
|
|
179
|
+ * @usage
|
|
180
|
+ *
|
|
181
|
+ * ```typescript
|
|
182
|
+ * import { Geolocation } from '@ionic-native/geolocation';
|
|
183
|
+ *
|
|
184
|
+ * ...
|
|
185
|
+ *
|
|
186
|
+ * constructor(private geolocation: Geolocation) {}
|
|
187
|
+ *
|
|
188
|
+ * ...
|
|
189
|
+ *
|
|
190
|
+ * this.geolocation.getCurrentPosition().then((resp) => {
|
|
191
|
+ * // resp.coords.latitude
|
|
192
|
+ * // resp.coords.longitude
|
|
193
|
+ * }).catch((error) => {
|
|
194
|
+ * console.log('Error getting location', error);
|
|
195
|
+ * });
|
|
196
|
+ *
|
|
197
|
+ * let watch = this.geolocation.watchPosition();
|
|
198
|
+ * watch.subscribe((data) => {
|
|
199
|
+ * // data can be a set of coordinates, or an error (if an error occurred).
|
|
200
|
+ * // data.coords.latitude
|
|
201
|
+ * // data.coords.longitude
|
|
202
|
+ * });
|
|
203
|
+ * ```
|
|
204
|
+ * @interfaces
|
|
205
|
+ * Coordinates
|
|
206
|
+ * Geoposition
|
|
207
|
+ * PositionError
|
|
208
|
+ * GeolocationOptions
|
|
209
|
+ */
|
|
210
|
+ Geolocation = __decorate([
|
|
211
|
+ Plugin({
|
|
212
|
+ pluginName: 'Geolocation',
|
|
213
|
+ plugin: 'cordova-plugin-geolocation',
|
|
214
|
+ pluginRef: 'navigator.geolocation',
|
|
215
|
+ repo: 'https://github.com/apache/cordova-plugin-geolocation',
|
|
216
|
+ install: 'ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you"',
|
|
217
|
+ installVariables: ['GEOLOCATION_USAGE_DESCRIPTION'],
|
|
218
|
+ platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Windows']
|
|
219
|
+ })
|
|
220
|
+ ], Geolocation);
|
|
221
|
+ return Geolocation;
|
|
222
|
+}(IonicNativePlugin));
|
|
223
|
+export { Geolocation };
|
|
224
|
+//# sourceMappingURL=index.js.map
|