@nativescript-community/ui-mapbox 6.2.27 → 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 CHANGED
@@ -3,6 +3,10 @@
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
+
6
10
  ## [6.2.27](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.26...v6.2.27) (2023-12-18)
7
11
 
8
12
  **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 = "fill" | "line" | "symbol" | "circle" | "heatmap" | "fill-extrusion" | "raster" | "hillshade" | "background" | "sky";
201
- export type SupportedLayerType = LayerType & ("line" | "circle" | "fill" | "symbol" | "raster");
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;
package/common.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Color, ContentView, ImageSource, Property, Trace, Utils, booleanConverter } from '@nativescript/core';
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"] = Trace.messageType.log] = "log";
10
- CLogTypes[CLogTypes["info"] = Trace.messageType.info] = "info";
11
- CLogTypes[CLogTypes["warning"] = Trace.messageType.warn] = "warning";
12
- CLogTypes[CLogTypes["error"] = Trace.messageType.error] = "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);
@@ -84,15 +84,15 @@ MapboxCommon.defaults = {
84
84
  top: 0,
85
85
  bottom: 0
86
86
  },
87
- zoomLevel: 0,
88
- 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
89
89
  locationComponentOptions: {},
90
- hideLogo: false,
91
- logoPosition: ControlPosition.BOTTOM_LEFT,
90
+ hideLogo: false, // required for the 'starter' plan
91
+ logoPosition: ControlPosition.BOTTOM_LEFT, // The default position mimics constructor of MapboxMapOptions
92
92
  hideAttribution: true,
93
- attributionPosition: ControlPosition.BOTTOM_LEFT,
93
+ attributionPosition: ControlPosition.BOTTOM_LEFT, // The default position mimics constructor of MapboxMapOptions
94
94
  hideCompass: false,
95
- compassPosition: ControlPosition.TOP_RIGHT,
95
+ compassPosition: ControlPosition.TOP_RIGHT, // The default position mimics constructor of MapboxMapOptions
96
96
  disableRotation: false,
97
97
  disableScroll: false,
98
98
  disableZoom: false,
package/index.android.js CHANGED
@@ -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, padding), durationMs, null);
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 padding = options.padding !== undefined ? options.padding : 25, animated = options.animated === undefined || options.animated, durationMs = animated ? 1000 : 0;
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(com.mapbox.mapboxsdk.camera.CameraUpdateFactory.newLatLngBounds(bounds, padding), durationMs);
1872
+ this._mapboxMapInstance.easeCamera(cameraUpdate, durationMs);
1864
1873
  }
1865
1874
  else {
1866
- this._mapboxMapInstance.moveCamera(com.mapbox.mapboxsdk.camera.CameraUpdateFactory.newLatLngBounds(bounds, padding));
1875
+ this._mapboxMapInstance.moveCamera(cameraUpdate);
1867
1876
  }
1868
1877
  setTimeout(() => {
1869
1878
  resolve();
package/index.ios.js CHANGED
@@ -1565,13 +1565,10 @@ export class Mapbox extends MapboxCommon {
1565
1565
  let cam;
1566
1566
  if (options.bounds) {
1567
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 };
1568
1570
  // support defined padding
1569
- const insets = {
1570
- top: padding,
1571
- left: padding,
1572
- bottom: padding,
1573
- right: padding
1574
- };
1571
+ const insets = { top, left, bottom, right };
1575
1572
  const bounds = {
1576
1573
  sw: CLLocationCoordinate2DMake(options.bounds.south, options.bounds.west),
1577
1574
  ne: CLLocationCoordinate2DMake(options.bounds.north, options.bounds.east)
@@ -1844,8 +1841,29 @@ export class Mapbox extends MapboxCommon {
1844
1841
  ne: CLLocationCoordinate2DMake(options.bounds.north, options.bounds.east)
1845
1842
  };
1846
1843
  const animated = options.animated === undefined || options.animated;
1847
- // support defined padding
1848
- const padding = options.padding !== undefined ? { top: options.padding, left: options.padding, bottom: options.padding, right: options.padding } : { top: 25, left: 25, bottom: 25, right: 25 };
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
+ };
1849
1867
  theMap.setVisibleCoordinateBoundsEdgePaddingAnimated(bounds, padding, animated);
1850
1868
  resolve();
1851
1869
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-mapbox",
3
- "version": "6.2.27",
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": "fa5f56e40f5345d2a09fd7518db482b5559f94af"
57
+ "gitHead": "6e61158c659952d2048448fbbd7a7838b2edf20d"
58
58
  }