@nativescript-community/ui-mapbox 6.2.23 → 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,22 @@
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
+
14
+ ## [6.2.25](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.24...v6.2.25) (2023-12-07)
15
+
16
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
17
+
18
+ ## [6.2.24](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.23...v6.2.24) (2023-12-07)
19
+
20
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
21
+
6
22
  ## [6.2.23](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.22...v6.2.23) (2023-11-29)
7
23
 
8
24
  ### Bug Fixes
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;
@@ -496,7 +522,7 @@ export interface MapboxApi {
496
522
  getLayer(name: string, nativeMap?: any): Promise<LayerCommon>;
497
523
  getLayers(nativeMap?: any): Promise<LayerCommon[]>;
498
524
  getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
499
- addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
525
+ addImage(imageId: string, imagePath: string, nativeMap?: any): Promise<void>;
500
526
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
501
527
  project(data: LatLng): {
502
528
  x: number;
@@ -510,30 +536,11 @@ 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>;
543
+ protected fetchImageSource(imagePath: string): Promise<ImageSource>;
537
544
  }
538
545
  /**
539
546
  * Interface definition for a View of a mapbox map.
@@ -583,7 +590,7 @@ export interface MapboxViewApi {
583
590
  getLayer(name: string, nativeMap?: any): Promise<LayerCommon>;
584
591
  getLayers(nativeMap?: any): Promise<LayerCommon[]>;
585
592
  getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
586
- addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
593
+ addImage(imageId: string, imagePath: string, nativeMap?: any): Promise<void>;
587
594
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
588
595
  destroy(): Promise<any>;
589
596
  onStart(): Promise<any>;
@@ -664,7 +671,7 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
664
671
  getLayer(name: string, nativeMap?: any): Promise<LayerCommon>;
665
672
  getLayers(nativeMap?: any): Promise<LayerCommon[]>;
666
673
  getImage(imageId: string): Promise<ImageSource>;
667
- addImage(imageId: string, image: string): Promise<void>;
674
+ addImage(imageId: string, imagePath: string): Promise<void>;
668
675
  removeImage(imageId: string): Promise<void>;
669
676
  destroy(): Promise<any>;
670
677
  onStart(): Promise<any>;
@@ -696,9 +703,12 @@ export declare const longitudeProperty: Property<MapboxViewCommonBase, number>;
696
703
  export declare const showUserLocationProperty: Property<MapboxViewCommonBase, boolean>;
697
704
  export declare const locationComponentOptionsProperty: Property<MapboxViewCommonBase, object>;
698
705
  export declare const hideLogoProperty: Property<MapboxViewCommonBase, boolean>;
706
+ export declare const logoPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
699
707
  export declare const hideAttributionProperty: Property<MapboxViewCommonBase, boolean>;
708
+ export declare const attributionPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
700
709
  export declare const telemetryProperty: Property<MapboxViewCommonBase, boolean>;
701
710
  export declare const hideCompassProperty: Property<MapboxViewCommonBase, boolean>;
711
+ export declare const compassPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
702
712
  export declare const disableZoomProperty: Property<MapboxViewCommonBase, boolean>;
703
713
  export declare const disableRotationProperty: Property<MapboxViewCommonBase, boolean>;
704
714
  export declare const disableScrollProperty: Property<MapboxViewCommonBase, boolean>;
@@ -721,5 +731,5 @@ export declare abstract class MapboxViewBase extends MapboxViewCommonBase {
721
731
  static moveEndEvent: string;
722
732
  static locationPermissionGrantedEvent: string;
723
733
  static locationPermissionDeniedEvent: string;
724
- protected config: any;
734
+ protected config: Partial<ShowOptions>;
725
735
  }
package/common.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Color, ContentView, ImageSource, Property, Trace, booleanConverter } from '@nativescript/core';
1
+ import { Color, ContentView, ImageSource, Property, Trace, Utils, booleanConverter } from '@nativescript/core';
2
2
  export * from './geo.utils';
3
3
  export * from './expression/expression-parser';
4
4
  export * from './layers/layer-factory';
@@ -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;
@@ -57,10 +65,19 @@ export class MapboxCommon {
57
65
  async hasFineLocationPermission() {
58
66
  return true;
59
67
  }
68
+ async fetchImageSource(imagePath) {
69
+ if (Utils.isDataURI(imagePath)) {
70
+ const [, base64] = imagePath.split(';base64,');
71
+ return ImageSource.fromBase64Sync(base64);
72
+ }
73
+ if (Utils.isFileOrResourcePath(imagePath)) {
74
+ return ImageSource.fromFileOrResourceSync(imagePath);
75
+ }
76
+ return ImageSource.fromUrl(imagePath);
77
+ }
60
78
  }
61
79
  MapboxCommon.defaults = {
62
80
  style: MapStyle.STREETS.toString(),
63
- mapStyle: MapStyle.STREETS.toString(),
64
81
  margins: {
65
82
  left: 0,
66
83
  right: 0,
@@ -71,8 +88,11 @@ MapboxCommon.defaults = {
71
88
  showUserLocation: false,
72
89
  locationComponentOptions: {},
73
90
  hideLogo: false,
91
+ logoPosition: ControlPosition.BOTTOM_LEFT,
74
92
  hideAttribution: true,
93
+ attributionPosition: ControlPosition.BOTTOM_LEFT,
75
94
  hideCompass: false,
95
+ compassPosition: ControlPosition.TOP_RIGHT,
76
96
  disableRotation: false,
77
97
  disableScroll: false,
78
98
  disableZoom: false,
@@ -230,8 +250,8 @@ export class MapboxViewCommonBase extends ContentView {
230
250
  getImage(imageId) {
231
251
  return this.mapbox.getImage(imageId, this.getNativeMapView());
232
252
  }
233
- addImage(imageId, image) {
234
- return this.mapbox.addImage(imageId, image, this.getNativeMapView());
253
+ addImage(imageId, imagePath) {
254
+ return this.mapbox.addImage(imageId, imagePath, this.getNativeMapView());
235
255
  }
236
256
  removeImage(imageId) {
237
257
  return this.mapbox.removeImage(imageId, this.getNativeMapView());
@@ -299,12 +319,22 @@ export const hideLogoProperty = new Property({
299
319
  valueConverter: booleanConverter
300
320
  });
301
321
  hideLogoProperty.register(MapboxViewCommonBase);
322
+ export const logoPositionProperty = new Property({
323
+ name: 'logoPosition',
324
+ defaultValue: MapboxCommon.defaults.logoPosition
325
+ });
326
+ logoPositionProperty.register(MapboxViewCommonBase);
302
327
  export const hideAttributionProperty = new Property({
303
328
  name: 'hideAttribution',
304
329
  defaultValue: MapboxCommon.defaults.hideAttribution,
305
330
  valueConverter: booleanConverter
306
331
  });
307
332
  hideAttributionProperty.register(MapboxViewCommonBase);
333
+ export const attributionPositionProperty = new Property({
334
+ name: 'attributionPosition',
335
+ defaultValue: MapboxCommon.defaults.attributionPosition
336
+ });
337
+ attributionPositionProperty.register(MapboxViewCommonBase);
308
338
  export const telemetryProperty = new Property({
309
339
  name: 'telemetry',
310
340
  defaultValue: false,
@@ -317,6 +347,11 @@ export const hideCompassProperty = new Property({
317
347
  valueConverter: booleanConverter
318
348
  });
319
349
  hideCompassProperty.register(MapboxViewCommonBase);
350
+ export const compassPositionProperty = new Property({
351
+ name: 'compassPosition',
352
+ defaultValue: MapboxCommon.defaults.compassPosition
353
+ });
354
+ compassPositionProperty.register(MapboxViewCommonBase);
320
355
  export const disableZoomProperty = new Property({
321
356
  name: 'disableZoom',
322
357
  defaultValue: MapboxCommon.defaults.disableZoom,
@@ -366,7 +401,6 @@ export class MapboxViewBase extends MapboxViewCommonBase {
366
401
  }
367
402
  [mapStyleProperty.setNative](value) {
368
403
  this.config.style = value;
369
- this.config.mapStyle = value;
370
404
  }
371
405
  [accessTokenProperty.setNative](value) {
372
406
  this.config.accessToken = value;
@@ -391,12 +425,21 @@ export class MapboxViewBase extends MapboxViewCommonBase {
391
425
  [hideLogoProperty.setNative](value) {
392
426
  this.config.hideLogo = value;
393
427
  }
428
+ [logoPositionProperty.setNative](value) {
429
+ this.config.logoPosition = value;
430
+ }
394
431
  [hideAttributionProperty.setNative](value) {
395
432
  this.config.hideAttribution = value;
396
433
  }
434
+ [attributionPositionProperty.setNative](value) {
435
+ this.config.attributionPosition = value;
436
+ }
397
437
  [hideCompassProperty.setNative](value) {
398
438
  this.config.hideCompass = value;
399
439
  }
440
+ [compassPositionProperty.setNative](value) {
441
+ this.config.compassPosition = value;
442
+ }
400
443
  [disableZoomProperty.setNative](value) {
401
444
  this.config.disableZoom = value;
402
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
  *
@@ -249,7 +249,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
249
249
  */
250
250
  setMapStyle(style: string | MapStyle, nativeMapViewInstance?: any): Promise<void>;
251
251
  getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
252
- addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
252
+ addImage(imageId: string, imagePath: string, nativeMap?: any): Promise<void>;
253
253
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
254
254
  addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<void>;
255
255
  removeMarkers(ids?: any, nativeMap?: any): Promise<void>;
@@ -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
@@ -4,10 +4,10 @@
4
4
  * @todo FIXME: The gcFix() implementation currently assumes only one map visible at a time.
5
5
  */
6
6
  import { request } from '@nativescript-community/perms';
7
- import { AndroidApplication, Application, Color, File, Http, Image, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
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, MapboxTraceCategory, 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;
@@ -987,19 +987,16 @@ export class Mapbox extends MapboxCommon {
987
987
  }
988
988
  });
989
989
  }
990
- async addImage(imageId, image, nativeMap) {
991
- return new Promise((resolve, reject) => {
990
+ async addImage(imageId, imagePath, nativeMap) {
991
+ return new Promise(async (resolve, reject) => {
992
992
  const theMap = nativeMap || this._mapboxMapInstance;
993
993
  if (!theMap) {
994
994
  reject('No map has been loaded');
995
995
  return;
996
996
  }
997
- if (!image.startsWith('res://')) {
998
- image = path.join(knownFolders.currentApp().path, image.replace('~/', ''));
999
- }
1000
- const img = ImageSource.fromFileOrResourceSync(image);
1001
997
  try {
1002
- theMap.getStyle().addImage(imageId, img.android);
998
+ const imageSource = await this.fetchImageSource(imagePath);
999
+ theMap.getStyle().addImage(imageId, imageSource.android);
1003
1000
  resolve();
1004
1001
  }
1005
1002
  catch (ex) {
@@ -2521,12 +2518,15 @@ export class Mapbox extends MapboxCommon {
2521
2518
  _getMapboxMapOptions(settings) {
2522
2519
  const mapboxMapOptions = new com.mapbox.mapboxsdk.maps.MapboxMapOptions()
2523
2520
  .compassEnabled(!settings.hideCompass)
2521
+ .compassGravity(Mapbox.mapPositionToGravity(settings.compassPosition))
2524
2522
  .rotateGesturesEnabled(!settings.disableRotation)
2525
2523
  .scrollGesturesEnabled(!settings.disableScroll)
2526
2524
  .tiltGesturesEnabled(!settings.disableTilt)
2527
2525
  .zoomGesturesEnabled(!settings.disableZoom)
2528
2526
  .attributionEnabled(!settings.hideAttribution)
2529
- .logoEnabled(!settings.hideLogo);
2527
+ .attributionGravity(Mapbox.mapPositionToGravity(settings.attributionPosition))
2528
+ .logoEnabled(!settings.hideLogo)
2529
+ .logoGravity(Mapbox.mapPositionToGravity(settings.logoPosition));
2530
2530
  // zoomlevel is not applied unless center is set
2531
2531
  if (settings.zoomLevel && !settings.center) {
2532
2532
  // Eiffel tower, Paris
@@ -2543,6 +2543,18 @@ export class Mapbox extends MapboxCommon {
2543
2543
  }
2544
2544
  return mapboxMapOptions;
2545
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
+ }
2546
2558
  /**
2547
2559
  * convert string to camera mode constant.
2548
2560
  *
package/index.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
43
43
  onDestroy(nativeMap?: any): Promise<void>;
44
44
  setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<void>;
45
45
  getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
46
- addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
46
+ addImage(imageId: string, imagePath: string, nativeMap?: any): Promise<void>;
47
47
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
48
48
  addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<void>;
49
49
  removeMarkers(ids?: any, nativeMap?: any): Promise<void>;
package/index.ios.d.ts CHANGED
@@ -111,7 +111,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
111
111
  */
112
112
  setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<void>;
113
113
  getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
114
- addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
114
+ addImage(imageId: string, imagePath: string, nativeMap?: any): Promise<void>;
115
115
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
116
116
  addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<void>;
117
117
  removeMarkers(ids?: any, nativeMap?: any): Promise<void>;
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, MapboxTraceCategory, 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);
@@ -998,20 +1013,16 @@ export class Mapbox extends MapboxCommon {
998
1013
  }
999
1014
  });
1000
1015
  }
1001
- async addImage(imageId, image, nativeMap) {
1002
- return new Promise((resolve, reject) => {
1016
+ async addImage(imageId, imagePath, nativeMap) {
1017
+ return new Promise(async (resolve, reject) => {
1003
1018
  const theMap = nativeMap || this._mapboxViewInstance;
1004
1019
  if (!theMap) {
1005
1020
  reject('No map has been loaded');
1006
1021
  return;
1007
1022
  }
1008
- if (!image.startsWith('res://')) {
1009
- const appPath = knownFolders.currentApp().path;
1010
- image = appPath + '/' + image.replace('~/', '');
1011
- }
1012
- const img = ImageSource.fromFileOrResourceSync(image);
1013
1023
  try {
1014
- theMap.style.setImageForName(img.ios, imageId);
1024
+ const imageSource = await this.fetchImageSource(imagePath);
1025
+ theMap.style.setImageForName(imageSource.ios, imageId);
1015
1026
  resolve();
1016
1027
  }
1017
1028
  catch (ex) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-mapbox",
3
- "version": "6.2.23",
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": "48aa53e1c2ab793bc664069245b6418399c11aa4"
57
+ "gitHead": "fa5f56e40f5345d2a09fd7518db482b5559f94af"
58
58
  }