@nativescript-community/ui-mapbox 6.2.25 → 6.2.28
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 +12 -0
- package/common.d.ts +45 -31
- package/common.js +43 -10
- package/index.android.d.ts +4 -3
- package/index.android.js +30 -6
- package/index.ios.js +42 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.28](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.27...v6.2.28) (2024-07-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-mapbox
|
|
9
|
+
|
|
10
|
+
## [6.2.27](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.26...v6.2.27) (2023-12-18)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-mapbox
|
|
13
|
+
|
|
14
|
+
## [6.2.26](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.25...v6.2.26) (2023-12-18)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-mapbox
|
|
17
|
+
|
|
6
18
|
## [6.2.25](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.24...v6.2.25) (2023-12-07)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @nativescript-community/ui-mapbox
|
package/common.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export * from './layers/layer-factory';
|
|
|
5
5
|
export * from './layers/parser/property-parser';
|
|
6
6
|
export declare const MapboxTraceCategory = "NativescriptMapbox";
|
|
7
7
|
export declare enum CLogTypes {
|
|
8
|
-
log,
|
|
9
|
-
info,
|
|
10
|
-
warning,
|
|
11
|
-
error
|
|
8
|
+
log = 0,
|
|
9
|
+
info = 1,
|
|
10
|
+
warning = 2,
|
|
11
|
+
error = 3
|
|
12
12
|
}
|
|
13
13
|
export declare const CLog: (type: CLogTypes, ...args: any[]) => void;
|
|
14
14
|
export declare enum MapStyle {
|
|
@@ -168,7 +168,12 @@ export interface SetViewportOptions {
|
|
|
168
168
|
/**
|
|
169
169
|
* Optional padding.
|
|
170
170
|
*/
|
|
171
|
-
padding?: number
|
|
171
|
+
padding?: number | {
|
|
172
|
+
top?: number;
|
|
173
|
+
left?: number;
|
|
174
|
+
right?: number;
|
|
175
|
+
bottom?: number;
|
|
176
|
+
};
|
|
172
177
|
}
|
|
173
178
|
export interface DeleteOfflineRegionOptions {
|
|
174
179
|
/**
|
|
@@ -197,8 +202,8 @@ export interface AddGeoJsonClusteredOptions {
|
|
|
197
202
|
clusterRadius?: number;
|
|
198
203
|
clusters?: MapboxCluster[];
|
|
199
204
|
}
|
|
200
|
-
export type LayerType =
|
|
201
|
-
export type SupportedLayerType = LayerType & (
|
|
205
|
+
export type LayerType = 'fill' | 'line' | 'symbol' | 'circle' | 'heatmap' | 'fill-extrusion' | 'raster' | 'hillshade' | 'background' | 'sky';
|
|
206
|
+
export type SupportedLayerType = LayerType & ('line' | 'circle' | 'fill' | 'symbol' | 'raster');
|
|
202
207
|
export interface AddLayerOptions {
|
|
203
208
|
id: string;
|
|
204
209
|
source: string;
|
|
@@ -314,6 +319,12 @@ export interface ListOfflineRegionsOptions {
|
|
|
314
319
|
*/
|
|
315
320
|
accessToken?: string;
|
|
316
321
|
}
|
|
322
|
+
export declare enum ControlPosition {
|
|
323
|
+
TOP_LEFT = 0,
|
|
324
|
+
TOP_RIGHT = 1,
|
|
325
|
+
BOTTOM_LEFT = 2,
|
|
326
|
+
BOTTOM_RIGHT = 3
|
|
327
|
+
}
|
|
317
328
|
/**
|
|
318
329
|
* The options object passed into the show function.
|
|
319
330
|
*/
|
|
@@ -322,9 +333,9 @@ export interface ShowOptions {
|
|
|
322
333
|
/**
|
|
323
334
|
* default 'streets'
|
|
324
335
|
*/
|
|
325
|
-
style?: MapStyle;
|
|
336
|
+
style?: string | MapStyle;
|
|
326
337
|
margins?: ShowOptionsMargins;
|
|
327
|
-
center?: LatLng
|
|
338
|
+
center?: Partial<LatLng>;
|
|
328
339
|
/**
|
|
329
340
|
* default 0 (which is almost the entire planet)
|
|
330
341
|
*/
|
|
@@ -337,14 +348,26 @@ export interface ShowOptions {
|
|
|
337
348
|
* default false (required for the 'starter' plan)
|
|
338
349
|
*/
|
|
339
350
|
hideLogo?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* default BOTTOM_LEFT
|
|
353
|
+
*/
|
|
354
|
+
logoPosition?: ControlPosition;
|
|
340
355
|
/**
|
|
341
356
|
* default true
|
|
342
357
|
*/
|
|
343
358
|
hideAttribution?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* default BOTTOM_LEFT
|
|
361
|
+
*/
|
|
362
|
+
attributionPosition?: ControlPosition;
|
|
344
363
|
/**
|
|
345
364
|
* default false
|
|
346
365
|
*/
|
|
347
366
|
hideCompass?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* default TOP_RIGHT
|
|
369
|
+
*/
|
|
370
|
+
compassPosition?: ControlPosition;
|
|
348
371
|
/**
|
|
349
372
|
* default false
|
|
350
373
|
*/
|
|
@@ -397,6 +420,14 @@ export interface ShowOptions {
|
|
|
397
420
|
* Android parent View
|
|
398
421
|
*/
|
|
399
422
|
parentView?: any;
|
|
423
|
+
/**
|
|
424
|
+
* On Android by default there is a 200ms delay before showing the map to work around a race condition.
|
|
425
|
+
*/
|
|
426
|
+
delay?: number;
|
|
427
|
+
/**
|
|
428
|
+
* See https://docs.mapbox.com/archive/android/maps/api/9.0.0/com/mapbox/mapboxsdk/location/LocationComponentOptions.html
|
|
429
|
+
*/
|
|
430
|
+
locationComponentOptions: any;
|
|
400
431
|
}
|
|
401
432
|
export interface ShowResult {
|
|
402
433
|
ios: any;
|
|
@@ -510,27 +541,7 @@ export interface MapboxApi {
|
|
|
510
541
|
export declare abstract class MapboxCommon implements MapboxCommonApi {
|
|
511
542
|
view?: MapboxViewCommonBase;
|
|
512
543
|
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
|
-
};
|
|
544
|
+
static defaults: Partial<ShowOptions>;
|
|
534
545
|
static merge(obj1: {}, obj2: {}): any;
|
|
535
546
|
requestFineLocationPermission(): Promise<any>;
|
|
536
547
|
hasFineLocationPermission(): Promise<boolean>;
|
|
@@ -697,9 +708,12 @@ export declare const longitudeProperty: Property<MapboxViewCommonBase, number>;
|
|
|
697
708
|
export declare const showUserLocationProperty: Property<MapboxViewCommonBase, boolean>;
|
|
698
709
|
export declare const locationComponentOptionsProperty: Property<MapboxViewCommonBase, object>;
|
|
699
710
|
export declare const hideLogoProperty: Property<MapboxViewCommonBase, boolean>;
|
|
711
|
+
export declare const logoPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
|
|
700
712
|
export declare const hideAttributionProperty: Property<MapboxViewCommonBase, boolean>;
|
|
713
|
+
export declare const attributionPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
|
|
701
714
|
export declare const telemetryProperty: Property<MapboxViewCommonBase, boolean>;
|
|
702
715
|
export declare const hideCompassProperty: Property<MapboxViewCommonBase, boolean>;
|
|
716
|
+
export declare const compassPositionProperty: Property<MapboxViewCommonBase, ControlPosition>;
|
|
703
717
|
export declare const disableZoomProperty: Property<MapboxViewCommonBase, boolean>;
|
|
704
718
|
export declare const disableRotationProperty: Property<MapboxViewCommonBase, boolean>;
|
|
705
719
|
export declare const disableScrollProperty: Property<MapboxViewCommonBase, boolean>;
|
|
@@ -722,5 +736,5 @@ export declare abstract class MapboxViewBase extends MapboxViewCommonBase {
|
|
|
722
736
|
static moveEndEvent: string;
|
|
723
737
|
static locationPermissionGrantedEvent: string;
|
|
724
738
|
static locationPermissionDeniedEvent: string;
|
|
725
|
-
protected config:
|
|
739
|
+
protected config: Partial<ShowOptions>;
|
|
726
740
|
}
|
package/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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';
|
|
@@ -6,10 +6,10 @@ export * from './layers/parser/property-parser';
|
|
|
6
6
|
export const MapboxTraceCategory = 'NativescriptMapbox';
|
|
7
7
|
export var CLogTypes;
|
|
8
8
|
(function (CLogTypes) {
|
|
9
|
-
CLogTypes[CLogTypes["log"] =
|
|
10
|
-
CLogTypes[CLogTypes["info"] =
|
|
11
|
-
CLogTypes[CLogTypes["warning"] =
|
|
12
|
-
CLogTypes[CLogTypes["error"] =
|
|
9
|
+
CLogTypes[CLogTypes["log"] = 0] = "log";
|
|
10
|
+
CLogTypes[CLogTypes["info"] = 1] = "info";
|
|
11
|
+
CLogTypes[CLogTypes["warning"] = 2] = "warning";
|
|
12
|
+
CLogTypes[CLogTypes["error"] = 3] = "error";
|
|
13
13
|
})(CLogTypes || (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);
|
|
@@ -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,19 +78,21 @@ 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,
|
|
77
84
|
top: 0,
|
|
78
85
|
bottom: 0
|
|
79
86
|
},
|
|
80
|
-
zoomLevel: 0,
|
|
81
|
-
showUserLocation: false,
|
|
87
|
+
zoomLevel: 0, // 0 (a big part of the world) to 20 (street level)
|
|
88
|
+
showUserLocation: false, // true requires adding `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in the .plist
|
|
82
89
|
locationComponentOptions: {},
|
|
83
|
-
hideLogo: false,
|
|
90
|
+
hideLogo: false, // required for the 'starter' plan
|
|
91
|
+
logoPosition: ControlPosition.BOTTOM_LEFT, // The default position mimics constructor of MapboxMapOptions
|
|
84
92
|
hideAttribution: true,
|
|
93
|
+
attributionPosition: ControlPosition.BOTTOM_LEFT, // The default position mimics constructor of MapboxMapOptions
|
|
85
94
|
hideCompass: false,
|
|
95
|
+
compassPosition: ControlPosition.TOP_RIGHT, // The default position mimics constructor of MapboxMapOptions
|
|
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
|
}
|
package/index.android.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class MapboxView extends MapboxViewBase {
|
|
|
30
30
|
/**
|
|
31
31
|
* programmatically include settings
|
|
32
32
|
*/
|
|
33
|
-
setConfig(settings:
|
|
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():
|
|
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:
|
|
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;
|
|
@@ -1543,11 +1543,14 @@ export class Mapbox extends MapboxCommon {
|
|
|
1543
1543
|
const durationMs = options.duration ? options.duration : 10000;
|
|
1544
1544
|
if (options.bounds) {
|
|
1545
1545
|
const padding = options.padding || 0;
|
|
1546
|
+
const defaultPadding = 0;
|
|
1547
|
+
// ensure padding is an object and assign default values
|
|
1548
|
+
const { top = defaultPadding, left = defaultPadding, bottom = defaultPadding, right = defaultPadding } = typeof padding === 'object' ? padding : { top: padding, left: padding, bottom: padding, right: padding };
|
|
1546
1549
|
const bounds = new com.mapbox.mapboxsdk.geometry.LatLngBounds.Builder()
|
|
1547
1550
|
.include(new com.mapbox.mapboxsdk.geometry.LatLng(options.bounds.north, options.bounds.east))
|
|
1548
1551
|
.include(new com.mapbox.mapboxsdk.geometry.LatLng(options.bounds.south, options.bounds.west))
|
|
1549
1552
|
.build();
|
|
1550
|
-
this._mapboxMapInstance.animateCamera(com.mapbox.mapboxsdk.camera.CameraUpdateFactory.newLatLngBounds(bounds,
|
|
1553
|
+
this._mapboxMapInstance.animateCamera(com.mapbox.mapboxsdk.camera.CameraUpdateFactory.newLatLngBounds(bounds, left, top, right, bottom), durationMs, null);
|
|
1551
1554
|
}
|
|
1552
1555
|
else {
|
|
1553
1556
|
const target = options.target;
|
|
@@ -1858,12 +1861,18 @@ export class Mapbox extends MapboxCommon {
|
|
|
1858
1861
|
.include(new com.mapbox.mapboxsdk.geometry.LatLng(options.bounds.north, options.bounds.east))
|
|
1859
1862
|
.include(new com.mapbox.mapboxsdk.geometry.LatLng(options.bounds.south, options.bounds.west))
|
|
1860
1863
|
.build();
|
|
1861
|
-
const
|
|
1864
|
+
const defaultPadding = 25;
|
|
1865
|
+
const padding = options.padding ?? defaultPadding;
|
|
1866
|
+
const animated = options.animated === undefined || options.animated;
|
|
1867
|
+
const durationMs = animated ? 1000 : 0;
|
|
1868
|
+
// ensure padding is an object and assign default values
|
|
1869
|
+
const { top = defaultPadding, left = defaultPadding, bottom = defaultPadding, right = defaultPadding } = typeof padding === 'object' ? padding : { top: padding, left: padding, bottom: padding, right: padding };
|
|
1870
|
+
const cameraUpdate = com.mapbox.mapboxsdk.camera.CameraUpdateFactory.newLatLngBounds(bounds, left, top, right, bottom);
|
|
1862
1871
|
if (animated) {
|
|
1863
|
-
this._mapboxMapInstance.easeCamera(
|
|
1872
|
+
this._mapboxMapInstance.easeCamera(cameraUpdate, durationMs);
|
|
1864
1873
|
}
|
|
1865
1874
|
else {
|
|
1866
|
-
this._mapboxMapInstance.moveCamera(
|
|
1875
|
+
this._mapboxMapInstance.moveCamera(cameraUpdate);
|
|
1867
1876
|
}
|
|
1868
1877
|
setTimeout(() => {
|
|
1869
1878
|
resolve();
|
|
@@ -2518,12 +2527,15 @@ export class Mapbox extends MapboxCommon {
|
|
|
2518
2527
|
_getMapboxMapOptions(settings) {
|
|
2519
2528
|
const mapboxMapOptions = new com.mapbox.mapboxsdk.maps.MapboxMapOptions()
|
|
2520
2529
|
.compassEnabled(!settings.hideCompass)
|
|
2530
|
+
.compassGravity(Mapbox.mapPositionToGravity(settings.compassPosition))
|
|
2521
2531
|
.rotateGesturesEnabled(!settings.disableRotation)
|
|
2522
2532
|
.scrollGesturesEnabled(!settings.disableScroll)
|
|
2523
2533
|
.tiltGesturesEnabled(!settings.disableTilt)
|
|
2524
2534
|
.zoomGesturesEnabled(!settings.disableZoom)
|
|
2525
2535
|
.attributionEnabled(!settings.hideAttribution)
|
|
2526
|
-
.
|
|
2536
|
+
.attributionGravity(Mapbox.mapPositionToGravity(settings.attributionPosition))
|
|
2537
|
+
.logoEnabled(!settings.hideLogo)
|
|
2538
|
+
.logoGravity(Mapbox.mapPositionToGravity(settings.logoPosition));
|
|
2527
2539
|
// zoomlevel is not applied unless center is set
|
|
2528
2540
|
if (settings.zoomLevel && !settings.center) {
|
|
2529
2541
|
// Eiffel tower, Paris
|
|
@@ -2540,6 +2552,18 @@ export class Mapbox extends MapboxCommon {
|
|
|
2540
2552
|
}
|
|
2541
2553
|
return mapboxMapOptions;
|
|
2542
2554
|
}
|
|
2555
|
+
static mapPositionToGravity(position) {
|
|
2556
|
+
switch (position) {
|
|
2557
|
+
case ControlPosition.TOP_LEFT:
|
|
2558
|
+
return android.view.Gravity.TOP | android.view.Gravity.START;
|
|
2559
|
+
case ControlPosition.TOP_RIGHT:
|
|
2560
|
+
return android.view.Gravity.TOP | android.view.Gravity.END;
|
|
2561
|
+
case ControlPosition.BOTTOM_LEFT:
|
|
2562
|
+
return android.view.Gravity.BOTTOM | android.view.Gravity.START;
|
|
2563
|
+
case ControlPosition.BOTTOM_RIGHT:
|
|
2564
|
+
return android.view.Gravity.BOTTOM | android.view.Gravity.END;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2543
2567
|
/**
|
|
2544
2568
|
* convert string to camera mode constant.
|
|
2545
2569
|
*
|
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);
|
|
@@ -1550,13 +1565,10 @@ export class Mapbox extends MapboxCommon {
|
|
|
1550
1565
|
let cam;
|
|
1551
1566
|
if (options.bounds) {
|
|
1552
1567
|
const padding = options.padding || 0;
|
|
1568
|
+
// ensure padding is an object and assign default values
|
|
1569
|
+
const { top = 0, left = 0, bottom = 0, right = 0 } = typeof padding === 'object' ? padding : { top: padding, left: padding, bottom: padding, right: padding };
|
|
1553
1570
|
// support defined padding
|
|
1554
|
-
const insets = {
|
|
1555
|
-
top: padding,
|
|
1556
|
-
left: padding,
|
|
1557
|
-
bottom: padding,
|
|
1558
|
-
right: padding
|
|
1559
|
-
};
|
|
1571
|
+
const insets = { top, left, bottom, right };
|
|
1560
1572
|
const bounds = {
|
|
1561
1573
|
sw: CLLocationCoordinate2DMake(options.bounds.south, options.bounds.west),
|
|
1562
1574
|
ne: CLLocationCoordinate2DMake(options.bounds.north, options.bounds.east)
|
|
@@ -1829,8 +1841,29 @@ export class Mapbox extends MapboxCommon {
|
|
|
1829
1841
|
ne: CLLocationCoordinate2DMake(options.bounds.north, options.bounds.east)
|
|
1830
1842
|
};
|
|
1831
1843
|
const animated = options.animated === undefined || options.animated;
|
|
1832
|
-
//
|
|
1833
|
-
const
|
|
1844
|
+
// define default padding
|
|
1845
|
+
const defaultPadding = 25;
|
|
1846
|
+
// check if padding is defined and whether it's an object or a single value
|
|
1847
|
+
const padding = options.padding !== undefined
|
|
1848
|
+
? typeof options.padding === 'object'
|
|
1849
|
+
? {
|
|
1850
|
+
top: options.padding.top ?? 0,
|
|
1851
|
+
left: options.padding.left ?? 0,
|
|
1852
|
+
bottom: options.padding.bottom ?? 0,
|
|
1853
|
+
right: options.padding.right ?? 0
|
|
1854
|
+
}
|
|
1855
|
+
: {
|
|
1856
|
+
top: options.padding,
|
|
1857
|
+
left: options.padding,
|
|
1858
|
+
bottom: options.padding,
|
|
1859
|
+
right: options.padding
|
|
1860
|
+
}
|
|
1861
|
+
: {
|
|
1862
|
+
top: defaultPadding,
|
|
1863
|
+
left: defaultPadding,
|
|
1864
|
+
bottom: defaultPadding,
|
|
1865
|
+
right: defaultPadding
|
|
1866
|
+
};
|
|
1834
1867
|
theMap.setVisibleCoordinateBoundsEdgePaddingAnimated(bounds, padding, animated);
|
|
1835
1868
|
resolve();
|
|
1836
1869
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript-community/ui-mapbox",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.28",
|
|
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": "
|
|
57
|
+
"gitHead": "6e61158c659952d2048448fbbd7a7838b2edf20d"
|
|
58
58
|
}
|