@nativescript-community/ui-mapbox 6.2.25 → 6.2.27

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.2.27](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.26...v6.2.27) (2023-12-18)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
9
+
10
+ ## [6.2.26](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.25...v6.2.26) (2023-12-18)
11
+
12
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
13
+
6
14
  ## [6.2.25](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.24...v6.2.25) (2023-12-07)
7
15
 
8
16
  **Note:** Version bump only for package @nativescript-community/ui-mapbox
package/common.d.ts CHANGED
@@ -314,6 +314,12 @@ export interface ListOfflineRegionsOptions {
314
314
  */
315
315
  accessToken?: string;
316
316
  }
317
+ export declare enum ControlPosition {
318
+ TOP_LEFT = 0,
319
+ TOP_RIGHT = 1,
320
+ BOTTOM_LEFT = 2,
321
+ BOTTOM_RIGHT = 3
322
+ }
317
323
  /**
318
324
  * The options object passed into the show function.
319
325
  */
@@ -322,9 +328,9 @@ export interface ShowOptions {
322
328
  /**
323
329
  * default 'streets'
324
330
  */
325
- style?: MapStyle;
331
+ style?: string | MapStyle;
326
332
  margins?: ShowOptionsMargins;
327
- center?: LatLng;
333
+ center?: Partial<LatLng>;
328
334
  /**
329
335
  * default 0 (which is almost the entire planet)
330
336
  */
@@ -337,14 +343,26 @@ export interface ShowOptions {
337
343
  * default false (required for the 'starter' plan)
338
344
  */
339
345
  hideLogo?: boolean;
346
+ /**
347
+ * default BOTTOM_LEFT
348
+ */
349
+ logoPosition?: ControlPosition;
340
350
  /**
341
351
  * default true
342
352
  */
343
353
  hideAttribution?: boolean;
354
+ /**
355
+ * default BOTTOM_LEFT
356
+ */
357
+ attributionPosition?: ControlPosition;
344
358
  /**
345
359
  * default false
346
360
  */
347
361
  hideCompass?: boolean;
362
+ /**
363
+ * default TOP_RIGHT
364
+ */
365
+ compassPosition?: ControlPosition;
348
366
  /**
349
367
  * default false
350
368
  */
@@ -397,6 +415,14 @@ export interface ShowOptions {
397
415
  * Android parent View
398
416
  */
399
417
  parentView?: any;
418
+ /**
419
+ * On Android by default there is a 200ms delay before showing the map to work around a race condition.
420
+ */
421
+ delay?: number;
422
+ /**
423
+ * See https://docs.mapbox.com/archive/android/maps/api/9.0.0/com/mapbox/mapboxsdk/location/LocationComponentOptions.html
424
+ */
425
+ locationComponentOptions: any;
400
426
  }
401
427
  export interface ShowResult {
402
428
  ios: any;
@@ -510,27 +536,7 @@ export interface MapboxApi {
510
536
  export declare abstract class MapboxCommon implements MapboxCommonApi {
511
537
  view?: MapboxViewCommonBase;
512
538
  constructor(view?: MapboxViewCommonBase);
513
- static defaults: {
514
- style: string;
515
- mapStyle: string;
516
- margins: {
517
- left: number;
518
- right: number;
519
- top: number;
520
- bottom: number;
521
- };
522
- zoomLevel: number;
523
- showUserLocation: boolean;
524
- locationComponentOptions: {};
525
- hideLogo: boolean;
526
- hideAttribution: boolean;
527
- hideCompass: boolean;
528
- disableRotation: boolean;
529
- disableScroll: boolean;
530
- disableZoom: boolean;
531
- disableTilt: boolean;
532
- delay: number;
533
- };
539
+ static defaults: Partial<ShowOptions>;
534
540
  static merge(obj1: {}, obj2: {}): any;
535
541
  requestFineLocationPermission(): Promise<any>;
536
542
  hasFineLocationPermission(): Promise<boolean>;
@@ -697,9 +703,12 @@ export declare const longitudeProperty: Property<MapboxViewCommonBase, number>;
697
703
  export declare const showUserLocationProperty: Property<MapboxViewCommonBase, boolean>;
698
704
  export declare const locationComponentOptionsProperty: Property<MapboxViewCommonBase, object>;
699
705
  export declare const hideLogoProperty: Property<MapboxViewCommonBase, boolean>;
706
+ export declare const logoPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
700
707
  export declare const hideAttributionProperty: Property<MapboxViewCommonBase, boolean>;
708
+ export declare const attributionPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
701
709
  export declare const telemetryProperty: Property<MapboxViewCommonBase, boolean>;
702
710
  export declare const hideCompassProperty: Property<MapboxViewCommonBase, boolean>;
711
+ export declare const compassPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
703
712
  export declare const disableZoomProperty: Property<MapboxViewCommonBase, boolean>;
704
713
  export declare const disableRotationProperty: Property<MapboxViewCommonBase, boolean>;
705
714
  export declare const disableScrollProperty: Property<MapboxViewCommonBase, boolean>;
@@ -722,5 +731,5 @@ export declare abstract class MapboxViewBase extends MapboxViewCommonBase {
722
731
  static moveEndEvent: string;
723
732
  static locationPermissionGrantedEvent: string;
724
733
  static locationPermissionDeniedEvent: string;
725
- protected config: any;
734
+ protected config: Partial<ShowOptions>;
726
735
  }
package/common.js CHANGED
@@ -27,6 +27,14 @@ export var MapStyle;
27
27
  MapStyle["TRAFFIC_NIGHT"] = "traffic_night";
28
28
  })(MapStyle || (MapStyle = {}));
29
29
  // ------------------------------------------------------------
30
+ export var ControlPosition;
31
+ (function (ControlPosition) {
32
+ ControlPosition[ControlPosition["TOP_LEFT"] = 0] = "TOP_LEFT";
33
+ ControlPosition[ControlPosition["TOP_RIGHT"] = 1] = "TOP_RIGHT";
34
+ ControlPosition[ControlPosition["BOTTOM_LEFT"] = 2] = "BOTTOM_LEFT";
35
+ ControlPosition[ControlPosition["BOTTOM_RIGHT"] = 3] = "BOTTOM_RIGHT";
36
+ })(ControlPosition || (ControlPosition = {}));
37
+ // ------------------------------------------------------------
30
38
  export class MapboxCommon {
31
39
  constructor(view) {
32
40
  this.view = view;
@@ -70,7 +78,6 @@ export class MapboxCommon {
70
78
  }
71
79
  MapboxCommon.defaults = {
72
80
  style: MapStyle.STREETS.toString(),
73
- mapStyle: MapStyle.STREETS.toString(),
74
81
  margins: {
75
82
  left: 0,
76
83
  right: 0,
@@ -81,8 +88,11 @@ MapboxCommon.defaults = {
81
88
  showUserLocation: false,
82
89
  locationComponentOptions: {},
83
90
  hideLogo: false,
91
+ logoPosition: ControlPosition.BOTTOM_LEFT,
84
92
  hideAttribution: true,
93
+ attributionPosition: ControlPosition.BOTTOM_LEFT,
85
94
  hideCompass: false,
95
+ compassPosition: ControlPosition.TOP_RIGHT,
86
96
  disableRotation: false,
87
97
  disableScroll: false,
88
98
  disableZoom: false,
@@ -309,12 +319,22 @@ export const hideLogoProperty = new Property({
309
319
  valueConverter: booleanConverter
310
320
  });
311
321
  hideLogoProperty.register(MapboxViewCommonBase);
322
+ export const logoPositionProperty = new Property({
323
+ name: 'logoPosition',
324
+ defaultValue: MapboxCommon.defaults.logoPosition
325
+ });
326
+ logoPositionProperty.register(MapboxViewCommonBase);
312
327
  export const hideAttributionProperty = new Property({
313
328
  name: 'hideAttribution',
314
329
  defaultValue: MapboxCommon.defaults.hideAttribution,
315
330
  valueConverter: booleanConverter
316
331
  });
317
332
  hideAttributionProperty.register(MapboxViewCommonBase);
333
+ export const attributionPositionProperty = new Property({
334
+ name: 'attributionPosition',
335
+ defaultValue: MapboxCommon.defaults.attributionPosition
336
+ });
337
+ attributionPositionProperty.register(MapboxViewCommonBase);
318
338
  export const telemetryProperty = new Property({
319
339
  name: 'telemetry',
320
340
  defaultValue: false,
@@ -327,6 +347,11 @@ export const hideCompassProperty = new Property({
327
347
  valueConverter: booleanConverter
328
348
  });
329
349
  hideCompassProperty.register(MapboxViewCommonBase);
350
+ export const compassPositionProperty = new Property({
351
+ name: 'compassPosition',
352
+ defaultValue: MapboxCommon.defaults.compassPosition
353
+ });
354
+ compassPositionProperty.register(MapboxViewCommonBase);
330
355
  export const disableZoomProperty = new Property({
331
356
  name: 'disableZoom',
332
357
  defaultValue: MapboxCommon.defaults.disableZoom,
@@ -376,7 +401,6 @@ export class MapboxViewBase extends MapboxViewCommonBase {
376
401
  }
377
402
  [mapStyleProperty.setNative](value) {
378
403
  this.config.style = value;
379
- this.config.mapStyle = value;
380
404
  }
381
405
  [accessTokenProperty.setNative](value) {
382
406
  this.config.accessToken = value;
@@ -401,12 +425,21 @@ export class MapboxViewBase extends MapboxViewCommonBase {
401
425
  [hideLogoProperty.setNative](value) {
402
426
  this.config.hideLogo = value;
403
427
  }
428
+ [logoPositionProperty.setNative](value) {
429
+ this.config.logoPosition = value;
430
+ }
404
431
  [hideAttributionProperty.setNative](value) {
405
432
  this.config.hideAttribution = value;
406
433
  }
434
+ [attributionPositionProperty.setNative](value) {
435
+ this.config.attributionPosition = value;
436
+ }
407
437
  [hideCompassProperty.setNative](value) {
408
438
  this.config.hideCompass = value;
409
439
  }
440
+ [compassPositionProperty.setNative](value) {
441
+ this.config.compassPosition = value;
442
+ }
410
443
  [disableZoomProperty.setNative](value) {
411
444
  this.config.disableZoom = value;
412
445
  }
@@ -30,7 +30,7 @@ export declare class MapboxView extends MapboxViewBase {
30
30
  /**
31
31
  * programmatically include settings
32
32
  */
33
- setConfig(settings: any): void;
33
+ setConfig(settings: ShowOptions): void;
34
34
  getNativeMapView(): any;
35
35
  /**
36
36
  * Return the Mapbox() API Shim instance
@@ -40,7 +40,7 @@ export declare class MapboxView extends MapboxViewBase {
40
40
  *
41
41
  * @see Mapbox
42
42
  */
43
- getMapboxApi(): any;
43
+ getMapboxApi(): MapboxApi;
44
44
  /**
45
45
  * Creates the native view.
46
46
  *
@@ -394,7 +394,8 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
394
394
  * @link https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
395
395
  * @link https://docs.mapbox.com/android/api/map-sdk/7.1.2/com/mapbox/mapboxsdk/maps/MapboxMapOptions.html
396
396
  */
397
- _getMapboxMapOptions(settings: any): com.mapbox.mapboxsdk.maps.MapboxMapOptions;
397
+ _getMapboxMapOptions(settings: ShowOptions): com.mapbox.mapboxsdk.maps.MapboxMapOptions;
398
+ private static mapPositionToGravity;
398
399
  /**
399
400
  * convert string to camera mode constant.
400
401
  *
package/index.android.js CHANGED
@@ -7,7 +7,7 @@ import { request } from '@nativescript-community/perms';
7
7
  import { AndroidApplication, Application, Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
8
8
  import { ExpressionParser } from './expression/expression-parser';
9
9
  import { Layer, LayerFactory } from './layers/layer-factory';
10
- import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
10
+ import { CLog, CLogTypes, ControlPosition, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
11
11
  // Export the enums for devs not using TS
12
12
  export * from './common';
13
13
  let libraryLoadedOverloaded = false;
@@ -2518,12 +2518,15 @@ export class Mapbox extends MapboxCommon {
2518
2518
  _getMapboxMapOptions(settings) {
2519
2519
  const mapboxMapOptions = new com.mapbox.mapboxsdk.maps.MapboxMapOptions()
2520
2520
  .compassEnabled(!settings.hideCompass)
2521
+ .compassGravity(Mapbox.mapPositionToGravity(settings.compassPosition))
2521
2522
  .rotateGesturesEnabled(!settings.disableRotation)
2522
2523
  .scrollGesturesEnabled(!settings.disableScroll)
2523
2524
  .tiltGesturesEnabled(!settings.disableTilt)
2524
2525
  .zoomGesturesEnabled(!settings.disableZoom)
2525
2526
  .attributionEnabled(!settings.hideAttribution)
2526
- .logoEnabled(!settings.hideLogo);
2527
+ .attributionGravity(Mapbox.mapPositionToGravity(settings.attributionPosition))
2528
+ .logoEnabled(!settings.hideLogo)
2529
+ .logoGravity(Mapbox.mapPositionToGravity(settings.logoPosition));
2527
2530
  // zoomlevel is not applied unless center is set
2528
2531
  if (settings.zoomLevel && !settings.center) {
2529
2532
  // Eiffel tower, Paris
@@ -2540,6 +2543,18 @@ export class Mapbox extends MapboxCommon {
2540
2543
  }
2541
2544
  return mapboxMapOptions;
2542
2545
  }
2546
+ static mapPositionToGravity(position) {
2547
+ switch (position) {
2548
+ case ControlPosition.TOP_LEFT:
2549
+ return android.view.Gravity.TOP | android.view.Gravity.START;
2550
+ case ControlPosition.TOP_RIGHT:
2551
+ return android.view.Gravity.TOP | android.view.Gravity.END;
2552
+ case ControlPosition.BOTTOM_LEFT:
2553
+ return android.view.Gravity.BOTTOM | android.view.Gravity.START;
2554
+ case ControlPosition.BOTTOM_RIGHT:
2555
+ return android.view.Gravity.BOTTOM | android.view.Gravity.END;
2556
+ }
2557
+ }
2543
2558
  /**
2544
2559
  * convert string to camera mode constant.
2545
2560
  *
package/index.ios.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
2
- import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
2
+ import { CLog, CLogTypes, ControlPosition, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
3
3
  import { Layer, LayerFactory } from './layers/layer-factory';
4
4
  import { ExpressionParser } from './expression/expression-parser';
5
5
  var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
@@ -403,8 +403,11 @@ let _markers = [];
403
403
  const _markerIconDownloadCache = [];
404
404
  const _setMapboxMapOptions = (mapView, settings) => {
405
405
  mapView.logoView.hidden = settings.hideLogo;
406
+ mapView.logoViewPosition = _mapControlPositionToOrnamentPosition(settings.logoPosition);
406
407
  mapView.attributionButton.hidden = settings.hideAttribution;
408
+ mapView.attributionButtonPosition = _mapControlPositionToOrnamentPosition(settings.attributionPosition);
407
409
  mapView.compassView.hidden = settings.hideCompass;
410
+ mapView.compassViewPosition = _mapControlPositionToOrnamentPosition(settings.compassPosition);
408
411
  mapView.rotateEnabled = !settings.disableRotation;
409
412
  mapView.scrollEnabled = !settings.disableScroll;
410
413
  mapView.zoomEnabled = !settings.disableZoom;
@@ -419,6 +422,18 @@ const _setMapboxMapOptions = (mapView, settings) => {
419
422
  mapView.showsUserLocation = settings.showUserLocation;
420
423
  mapView.autoresizingMask = 2 /* UIViewAutoresizing.FlexibleWidth */ | 16 /* UIViewAutoresizing.FlexibleHeight */;
421
424
  };
425
+ const _mapControlPositionToOrnamentPosition = (position) => {
426
+ switch (position) {
427
+ case ControlPosition.TOP_LEFT:
428
+ return 0 /* MGLOrnamentPosition.TopLeft */;
429
+ case ControlPosition.TOP_RIGHT:
430
+ return 1 /* MGLOrnamentPosition.TopRight */;
431
+ case ControlPosition.BOTTOM_LEFT:
432
+ return 2 /* MGLOrnamentPosition.BottomLeft */;
433
+ case ControlPosition.BOTTOM_RIGHT:
434
+ return 3 /* MGLOrnamentPosition.BottomRight */;
435
+ }
436
+ };
422
437
  const _getMapStyle = (input) => {
423
438
  if (input.startsWith('mapbox://styles') || input.startsWith('http://') || input.startsWith('https://')) {
424
439
  return NSURL.URLWithString(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-mapbox",
3
- "version": "6.2.25",
3
+ "version": "6.2.27",
4
4
  "description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
5
5
  "main": "index",
6
6
  "typings": "index.d.ts",
@@ -54,5 +54,5 @@
54
54
  "dependencies": {
55
55
  "@nativescript-community/perms": "^2.3.0"
56
56
  },
57
- "gitHead": "d30b7e286b25bbf34a2593d14932be196f5a025b"
57
+ "gitHead": "fa5f56e40f5345d2a09fd7518db482b5559f94af"
58
58
  }