@nativescript-community/ui-mapbox 6.2.19 → 6.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common.d.ts CHANGED
@@ -41,12 +41,28 @@ export interface Feature {
41
41
  properties: Object;
42
42
  }
43
43
  export interface AddPolygonOptions {
44
+ /**
45
+ * Set this in case you want to later pass it to 'removePolygons'. TODO doesn't exist yet ;)
46
+ */
44
47
  id?: any;
45
48
  points: LatLng[];
46
49
  fillColor?: string | Color;
50
+ /**
51
+ * Transparency / alpha, ranging from 0 to 1.
52
+ * Default fully opaque (1).
53
+ */
47
54
  fillOpacity?: number;
55
+ /**
56
+ * The line around the polygon. Barely visible on Android.
57
+ */
48
58
  strokeColor?: string | Color;
59
+ /**
60
+ * iOS only.
61
+ */
49
62
  strokeWidth?: number;
63
+ /**
64
+ * iOS only.
65
+ */
50
66
  strokeOpacity?: number;
51
67
  }
52
68
  export interface UserLocation {
@@ -57,20 +73,56 @@ export interface SetCenterOptions extends LatLng {
57
73
  animated?: boolean;
58
74
  }
59
75
  export interface AddPolylineOptions {
76
+ /**
77
+ * Set this in case you want to later pass it to 'removePolylines'.
78
+ */
60
79
  id?: any;
80
+ /**
81
+ * Width of the line, default 5.
82
+ */
61
83
  width?: number;
84
+ /**
85
+ * Color of the line, default black.
86
+ */
62
87
  color?: string | Color;
88
+ /**
89
+ * Transparency / alpha, ranging from 0 to 1.
90
+ * Default fully opaque (1).
91
+ */
63
92
  opacity?: number;
64
93
  points: LatLng[];
65
94
  }
66
95
  export interface MapboxMarker extends LatLng {
96
+ /**
97
+ * Set this in case you want to later pass it to 'removeMarker'.
98
+ */
67
99
  id?: any;
68
100
  title?: string;
69
101
  subtitle?: string;
102
+ /**
103
+ * Prefix with 'res://' and load a file from the resources folder.
104
+ * Details on how 'res://' is used can be found here: https://docs.nativescript.org/ui/images#load-images-from-resource
105
+ * Example: "res://icon.file"
106
+ */
70
107
  icon?: string;
108
+ /**
109
+ * The preferred way is using the 'icon' property, but you can still reference a local file directly.
110
+ * Example: "~/assets/markers/green_pin_marker.png"
111
+ */
71
112
  iconPath?: string;
113
+ /**
114
+ * A callback function to invoke when the marker is tapped.
115
+ */
72
116
  onTap?: Function;
117
+ /**
118
+ * A callback function to invoke when the callout (popup) of this marker is tapped.
119
+ */
73
120
  onCalloutTap?: Function;
121
+ /**
122
+ * Set to true to select the marker when rendered - effectively showing any configured callout.
123
+ * Note that only 1 callout will be shown at any time on a Mapbox map.
124
+ * Default false.
125
+ */
74
126
  selected?: boolean;
75
127
  update?: (newSettings: MapboxMarker) => void;
76
128
  ios?: any;
@@ -81,7 +133,13 @@ export interface SetZoomLevelOptions {
81
133
  animated: boolean;
82
134
  }
83
135
  export interface SetTiltOptions {
136
+ /**
137
+ * default 30 (degrees)
138
+ */
84
139
  tilt: number;
140
+ /**
141
+ * default 5000 (milliseconds)
142
+ */
85
143
  duration: number;
86
144
  }
87
145
  export interface ShowOptionsMargins {
@@ -102,11 +160,24 @@ export interface Viewport {
102
160
  }
103
161
  export interface SetViewportOptions {
104
162
  bounds: Bounds;
163
+ /**
164
+ * Add an animation of about 1 second.
165
+ * Default true.
166
+ */
105
167
  animated?: boolean;
168
+ /**
169
+ * Optional padding.
170
+ */
106
171
  padding?: number;
107
172
  }
108
173
  export interface DeleteOfflineRegionOptions {
174
+ /**
175
+ * The id of the offline region to delete.
176
+ */
109
177
  id?: string;
178
+ /**
179
+ * The name of the offline region to delete.
180
+ */
110
181
  name?: string;
111
182
  }
112
183
  export interface MapboxCluster {
@@ -114,7 +185,13 @@ export interface MapboxCluster {
114
185
  color: string;
115
186
  }
116
187
  export interface AddGeoJsonClusteredOptions {
188
+ /**
189
+ * A unique identifier, like: "earthquakes"
190
+ */
117
191
  name: string;
192
+ /**
193
+ * URL, like: "https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"
194
+ */
118
195
  data: string;
119
196
  clusterMaxZoom?: number;
120
197
  clusterRadius?: number;
@@ -127,15 +204,27 @@ export interface AddLayerOptions {
127
204
  source: string;
128
205
  sourceLayer: string;
129
206
  type: SupportedLayerType;
207
+ /**
208
+ * 'circle' paint properties
209
+ */
130
210
  circleColor?: string | Color;
131
211
  circleOpacity?: number;
132
212
  circleRadius?: number;
133
213
  circleStrokeColor?: string | Color;
134
214
  circleStrokeWidth?: number;
215
+ /**
216
+ * 'fill' paint properties
217
+ */
135
218
  fillColor?: string | Color;
136
219
  fillOpacity?: number;
220
+ /**
221
+ * 'line' layout properties
222
+ */
137
223
  lineCap?: string;
138
224
  lineJoin?: string;
225
+ /**
226
+ * 'line' paint properties
227
+ */
139
228
  lineColor?: string | Color;
140
229
  lineOpacity?: number;
141
230
  lineWidth?: number;
@@ -182,6 +271,9 @@ export declare type UserLocationCameraMode = 'NONE' | 'NONE_COMPASS' | 'NONE_GPS
182
271
  export interface TrackUserOptions {
183
272
  cameraMode: UserLocationCameraMode;
184
273
  renderMode?: string;
274
+ /**
275
+ * iOS only, as Android is always animated. Default true (because of Android).
276
+ */
185
277
  animated?: boolean;
186
278
  }
187
279
  export interface AddExtrusionOptions {
@@ -202,36 +294,108 @@ export interface DownloadProgress {
202
294
  expected: number;
203
295
  percentage: number;
204
296
  complete: boolean;
297
+ /**
298
+ * Android only, the size in bytes of the download so far.
299
+ */
205
300
  completedSize?: number;
206
301
  }
207
302
  export interface DownloadOfflineRegionOptions extends OfflineRegion {
208
303
  onProgress?: (data: DownloadProgress) => void;
304
+ /**
305
+ * Optional, used on Android only.
306
+ * Set this, in case no map has been show yet (and thus, no accessToken has been passed in yet).
307
+ */
209
308
  accessToken?: string;
210
309
  }
211
310
  export interface ListOfflineRegionsOptions {
311
+ /**
312
+ * Optional, used on Android only.
313
+ * Set this, in case no map has been show yet (and thus, no accessToken has been passed in yet).
314
+ */
212
315
  accessToken?: string;
213
316
  }
317
+ /**
318
+ * The options object passed into the show function.
319
+ */
214
320
  export interface ShowOptions {
215
321
  accessToken: string;
322
+ /**
323
+ * default 'streets'
324
+ */
216
325
  style?: MapStyle;
217
326
  margins?: ShowOptionsMargins;
218
327
  center?: LatLng;
328
+ /**
329
+ * default 0 (which is almost the entire planet)
330
+ */
219
331
  zoomLevel?: number;
332
+ /**
333
+ * default false (true requires adding `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` to the .plist)
334
+ */
220
335
  showUserLocation?: boolean;
336
+ /**
337
+ * default false (required for the 'starter' plan)
338
+ */
221
339
  hideLogo?: boolean;
340
+ /**
341
+ * default true
342
+ */
222
343
  hideAttribution?: boolean;
344
+ /**
345
+ * default false
346
+ */
223
347
  hideCompass?: boolean;
348
+ /**
349
+ * default false
350
+ */
224
351
  disableRotation?: boolean;
352
+ /**
353
+ * default false
354
+ */
225
355
  disableScroll?: boolean;
356
+ /**
357
+ * default false
358
+ */
226
359
  disableZoom?: boolean;
360
+ /**
361
+ * default false
362
+ */
227
363
  disableTilt?: boolean;
364
+ /**
365
+ * Immediately add markers to the map
366
+ */
228
367
  markers?: MapboxMarker[];
368
+ /**
369
+ * callback on location permission granted
370
+ *
371
+ * Android Only
372
+ */
229
373
  onLocationPermissionGranted?: any;
374
+ /**
375
+ * callback on location permission denied
376
+ *
377
+ * Android Only
378
+ */
230
379
  onLocationPermissionDenied?: any;
380
+ /**
381
+ * callback on Map Ready
382
+ */
231
383
  onMapReady?: any;
384
+ /**
385
+ * callback on scroll event
386
+ */
232
387
  onScrollEvent?: any;
388
+ /**
389
+ * callback on move begin event
390
+ */
233
391
  onMoveBeginEvent?: any;
392
+ /**
393
+ * Android context
394
+ */
234
395
  context?: any;
396
+ /**
397
+ * Android parent View
398
+ */
235
399
  parentView?: any;
236
400
  }
237
401
  export interface ShowResult {
@@ -243,6 +407,9 @@ export interface AnimateCameraOptions {
243
407
  bounds?: Bounds;
244
408
  padding?: number;
245
409
  zoomLevel?: number;
410
+ /**
411
+ * For iOS, in meters from the ground
412
+ */
246
413
  altitude?: number;
247
414
  bearing?: number;
248
415
  tilt?: number;
@@ -368,6 +535,9 @@ export declare abstract class MapboxCommon implements MapboxCommonApi {
368
535
  requestFineLocationPermission(): Promise<any>;
369
536
  hasFineLocationPermission(): Promise<boolean>;
370
537
  }
538
+ /**
539
+ * Interface definition for a View of a mapbox map.
540
+ */
371
541
  export interface MapboxViewApi {
372
542
  addMarkers(markers: MapboxMarker[]): Promise<any>;
373
543
  onMapEvent(eventName: any, id: any, callback: any): void;
@@ -431,10 +601,24 @@ export interface MapboxViewApi {
431
601
  y: number;
432
602
  }): LatLng;
433
603
  }
604
+ /**
605
+ * common base for views created in XML.
606
+ *
607
+ * Instead of returning a reference to the Mapbox API instance (class Mapbox) from the view
608
+ * the author decided to implement shim methods for a subset of the API. I'm not sure what the
609
+ * reasoning was.
610
+ *
611
+ * @see Mapbox
612
+ */
434
613
  export declare abstract class MapboxViewCommonBase extends ContentView implements MapboxViewApi {
435
614
  protected mapbox: MapboxApi;
436
615
  telemetry: boolean;
437
616
  abstract getNativeMapView(): any;
617
+ /**
618
+ * map event
619
+ *
620
+ * The base NativeScript ContentView class has on() and off() methods.
621
+ */
438
622
  onMapEvent(eventName: any, id: any, callback: any): void;
439
623
  offMapEvent(eventName: any, id: any): void;
440
624
  addMarkers(markers: MapboxMarker[]): Promise<any>;
@@ -498,6 +682,11 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
498
682
  y: number;
499
683
  }): LatLng;
500
684
  }
685
+ /**
686
+ * Properties definitions for the Mapbox XML tag.
687
+ *
688
+ * @link https://docs.nativescript.org/plugins/ui-plugin-custom
689
+ */
501
690
  export declare const mapReadyProperty: Property<MapboxViewCommonBase, string>;
502
691
  export declare const zoomLevelProperty: Property<MapboxViewCommonBase, number>;
503
692
  export declare const accessTokenProperty: Property<MapboxViewCommonBase, string>;
@@ -515,6 +704,16 @@ export declare const disableRotationProperty: Property<MapboxViewCommonBase, boo
515
704
  export declare const disableScrollProperty: Property<MapboxViewCommonBase, boolean>;
516
705
  export declare const disableTiltProperty: Property<MapboxViewCommonBase, boolean>;
517
706
  export declare const delayProperty: Property<MapboxViewCommonBase, number>;
707
+ /**
708
+ * base class for views created in XML
709
+ *
710
+ * This is the glue that creates a config object based on the XML attributes passed to
711
+ * the Mapbox XML tag.
712
+ *
713
+ * @see MapboxView
714
+ *
715
+ * @link https://docs.nativescript.org/plugins/ui-plugin-custom
716
+ */
518
717
  export declare abstract class MapboxViewBase extends MapboxViewCommonBase {
519
718
  static mapReadyEvent: string;
520
719
  static scrollEvent: string;
package/common.js CHANGED
@@ -14,6 +14,7 @@ export var CLogTypes;
14
14
  export const CLog = (type, ...args) => {
15
15
  Trace.write(args.map((a) => (a && typeof a === 'object' ? JSON.stringify(a) : a)).join(' '), MapboxTraceCategory, type);
16
16
  };
17
+ // ------------------------------------------------------------
17
18
  export var MapStyle;
18
19
  (function (MapStyle) {
19
20
  MapStyle["DARK"] = "dark";
@@ -25,22 +26,27 @@ export var MapStyle;
25
26
  MapStyle["TRAFFIC_DAY"] = "traffic_day";
26
27
  MapStyle["TRAFFIC_NIGHT"] = "traffic_night";
27
28
  })(MapStyle || (MapStyle = {}));
29
+ // ------------------------------------------------------------
28
30
  export class MapboxCommon {
29
31
  constructor(view) {
30
32
  this.view = view;
31
33
  }
32
34
  static merge(obj1, obj2) {
33
- const result = {};
35
+ // Our merge function
36
+ const result = {}; // return result
34
37
  for (const i in obj1) {
38
+ // for every property in obj1
35
39
  if (i in obj2 && typeof obj1[i] === 'object' && i !== null) {
36
- result[i] = this.merge(obj1[i], obj2[i]);
40
+ result[i] = this.merge(obj1[i], obj2[i]); // if it's an object, merge
37
41
  }
38
42
  else {
39
- result[i] = obj1[i];
43
+ result[i] = obj1[i]; // add it to result
40
44
  }
41
45
  }
42
46
  for (const i in obj2) {
47
+ // add the remaining properties from object 2
43
48
  if (i in result) {
49
+ // conflict
44
50
  continue;
45
51
  }
46
52
  result[i] = obj2[i];
@@ -73,7 +79,22 @@ MapboxCommon.defaults = {
73
79
  disableTilt: false,
74
80
  delay: 0
75
81
  };
82
+ // ----------------------------------------------------------------------------------------
83
+ /**
84
+ * common base for views created in XML.
85
+ *
86
+ * Instead of returning a reference to the Mapbox API instance (class Mapbox) from the view
87
+ * the author decided to implement shim methods for a subset of the API. I'm not sure what the
88
+ * reasoning was.
89
+ *
90
+ * @see Mapbox
91
+ */
76
92
  export class MapboxViewCommonBase extends ContentView {
93
+ /**
94
+ * map event
95
+ *
96
+ * The base NativeScript ContentView class has on() and off() methods.
97
+ */
77
98
  onMapEvent(eventName, id, callback) {
78
99
  return this.mapbox.onMapEvent(eventName, id, callback, this.getNativeMapView());
79
100
  }
@@ -243,6 +264,12 @@ export class MapboxViewCommonBase extends ContentView {
243
264
  return this.mapbox && this.mapbox.projectBack(screenCoordinate);
244
265
  }
245
266
  }
267
+ // -----------------------------------------------------------------
268
+ /**
269
+ * Properties definitions for the Mapbox XML tag.
270
+ *
271
+ * @link https://docs.nativescript.org/plugins/ui-plugin-custom
272
+ */
246
273
  export const mapReadyProperty = new Property({ name: 'mapReady' });
247
274
  mapReadyProperty.register(MapboxViewCommonBase);
248
275
  export const zoomLevelProperty = new Property({ name: 'zoomLevel' });
@@ -316,8 +343,21 @@ export const disableTiltProperty = new Property({
316
343
  disableTiltProperty.register(MapboxViewCommonBase);
317
344
  export const delayProperty = new Property({ name: 'delay', valueConverter: (v) => parseInt(v, 10) });
318
345
  delayProperty.register(MapboxViewCommonBase);
346
+ // -------------------------------------------------------------------------------------
347
+ /**
348
+ * base class for views created in XML
349
+ *
350
+ * This is the glue that creates a config object based on the XML attributes passed to
351
+ * the Mapbox XML tag.
352
+ *
353
+ * @see MapboxView
354
+ *
355
+ * @link https://docs.nativescript.org/plugins/ui-plugin-custom
356
+ */
319
357
  export class MapboxViewBase extends MapboxViewCommonBase {
320
358
  constructor() {
359
+ // this took forever to find. The component-builder module apparently
360
+ // looks for static members to find events on controls.
321
361
  super(...arguments);
322
362
  this.config = {};
323
363
  }
@@ -2,7 +2,7 @@ export class ExpressionParser {
2
2
  static parseJson(json) {
3
3
  const filterStr = NSString.stringWithString(JSON.stringify(json));
4
4
  const filterData = filterStr.dataUsingEncoding(NSUTF8StringEncoding);
5
- const filterJson = NSJSONSerialization.JSONObjectWithDataOptionsError(filterData, 1);
5
+ const filterJson = NSJSONSerialization.JSONObjectWithDataOptionsError(filterData, 1 /* NSJSONReadingOptions.MutableContainers */);
6
6
  const predicateFilter = NSPredicate.predicateWithMGLJSONObject(filterJson);
7
7
  return predicateFilter;
8
8
  }
package/geo.utils.d.ts CHANGED
@@ -1,3 +1,16 @@
1
1
  export declare class GeoUtils {
2
+ /**
3
+ * Is the current location within the given circle?
4
+ *
5
+ * @param {number} longitude to check
6
+ * @param {number} latitude to check
7
+ * @param {number} longitude center of circle
8
+ * @param {number} latitude center of circle
9
+ * @param {number} radius of circle in meters
10
+ *
11
+ * @return {boolean} true if the point is within the given geofence.
12
+ *
13
+ * @link https://stackoverflow.com/questions/24680247/check-if-a-latitude-and-longitude-is-within-a-circle-google-maps
14
+ */
2
15
  static isLocationInCircle(lng: any, lat: any, circleLng: any, circleLat: any, circleRadius: any): boolean;
3
16
  }
package/geo.utils.js CHANGED
@@ -1,4 +1,17 @@
1
1
  export class GeoUtils {
2
+ /**
3
+ * Is the current location within the given circle?
4
+ *
5
+ * @param {number} longitude to check
6
+ * @param {number} latitude to check
7
+ * @param {number} longitude center of circle
8
+ * @param {number} latitude center of circle
9
+ * @param {number} radius of circle in meters
10
+ *
11
+ * @return {boolean} true if the point is within the given geofence.
12
+ *
13
+ * @link https://stackoverflow.com/questions/24680247/check-if-a-latitude-and-longitude-is-within-a-circle-google-maps
14
+ */
2
15
  static isLocationInCircle(lng, lat, circleLng, circleLat, circleRadius) {
3
16
  const ky = 40000 / 360;
4
17
  const kx = Math.cos((Math.PI * circleLat) / 180.0) * ky;
@@ -10,5 +23,5 @@ export class GeoUtils {
10
23
  }
11
24
  return false;
12
25
  }
13
- }
26
+ } // END
14
27
  //# sourceMappingURL=geo.utils.js.map