@nativescript-community/ui-mapbox 6.2.12 → 6.2.15

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,30 @@
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.15](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.14...v6.2.15) (2022-03-03)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.2.14](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.13...v6.2.14) (2022-02-09)
15
+
16
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
17
+
18
+
19
+
20
+
21
+
22
+ ## [6.2.13](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.12...v6.2.13) (2022-01-19)
23
+
24
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
25
+
26
+
27
+
28
+
29
+
6
30
  ## [6.2.12](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.11...v6.2.12) (2022-01-17)
7
31
 
8
32
  **Note:** Version bump only for package @nativescript-community/ui-mapbox
package/common.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Color, ContentView, ImageSource, Property } from '@nativescript/core';
2
2
  export * from './geo.utils';
3
- export * from './filter/filter-parser';
3
+ export * from './expression/expression-parser';
4
4
  export * from './layers/layer-factory';
5
5
  export * from './layers/parser/property-parser';
6
6
  export declare const MapboxTraceCategory = "NativescriptMapbox";
@@ -120,11 +120,13 @@ export interface AddGeoJsonClusteredOptions {
120
120
  clusterRadius?: number;
121
121
  clusters?: MapboxCluster[];
122
122
  }
123
+ export declare type LayerType = "fill" | "line" | "symbol" | "circle" | "heatmap" | "fill-extrusion" | "raster" | "hillshade" | "background" | "sky";
124
+ export declare type SupportedLayerType = LayerType & ("line" | "circle" | "fill" | "symbol" | "raster");
123
125
  export interface AddLayerOptions {
124
126
  id: string;
125
127
  source: string;
126
128
  sourceLayer: string;
127
- type: string;
129
+ type: SupportedLayerType;
128
130
  circleColor?: string | Color;
129
131
  circleOpacity?: number;
130
132
  circleRadius?: number;
@@ -167,9 +169,13 @@ export interface GeoJSONSource extends Source {
167
169
  data?: any;
168
170
  minzoom?: number;
169
171
  maxzoom?: number;
172
+ lineMetrics?: boolean;
170
173
  cluster?: {
171
174
  radius: any;
172
175
  maxZoom: any;
176
+ properties?: {
177
+ [property: string]: [any, any];
178
+ };
173
179
  };
174
180
  }
175
181
  export declare type UserLocationCameraMode = 'NONE' | 'NONE_COMPASS' | 'NONE_GPS' | 'TRACKING' | 'TRACKING_COMPASS' | 'TRACKING_GPS' | 'TRACKING_GPS_NORTH';
@@ -250,6 +256,7 @@ export interface LayerCommon {
250
256
  getNativeInstance(): any;
251
257
  setFilter(filter: any[]): void;
252
258
  getFilter(): any[];
259
+ type(): LayerType;
253
260
  }
254
261
  export interface MapboxCommonApi {
255
262
  requestFineLocationPermission(): Promise<any>;
@@ -285,6 +292,7 @@ export interface MapboxApi {
285
292
  changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): void;
286
293
  forceUserLocationUpdate(location: any, nativeMap?: any): void;
287
294
  trackUser(options: TrackUserOptions, nativeMap?: any): Promise<void>;
295
+ getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
288
296
  addSource(id: string, options: AddSourceOptions, nativeMapView?: any): Promise<any>;
289
297
  updateSource(id: string, options: UpdateSourceOptions, nativeMapView?: any): Promise<any>;
290
298
  removeSource(id: string, nativeMap?: any): Promise<any>;
@@ -327,6 +335,10 @@ export interface MapboxApi {
327
335
  x: number;
328
336
  y: number;
329
337
  };
338
+ projectBack(point: {
339
+ x: number;
340
+ y: number;
341
+ }): LatLng;
330
342
  }
331
343
  export declare abstract class MapboxCommon implements MapboxCommonApi {
332
344
  view?: MapboxViewCommonBase;
@@ -382,11 +394,13 @@ export interface MapboxViewApi {
382
394
  setTilt(options: SetTiltOptions): Promise<any>;
383
395
  getUserLocation(): Promise<UserLocation>;
384
396
  trackUser(options: TrackUserOptions): Promise<any>;
397
+ getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
385
398
  showUserLocationMarker(options: any): void;
386
399
  hideUserLocationMarker(options: any): void;
387
400
  changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
388
401
  forceUserLocationUpdate(location: any): void;
389
402
  addSource(id: string, options: AddSourceOptions): Promise<any>;
403
+ updateSource(id: string, options: UpdateSourceOptions): Promise<any>;
390
404
  removeSource(id: string, nativeMap?: any): Promise<any>;
391
405
  addLayer(style: any, belowLayerId?: string): Promise<any>;
392
406
  removeLayer(id: string): Promise<any>;
@@ -408,6 +422,14 @@ export interface MapboxViewApi {
408
422
  onStop(): Promise<any>;
409
423
  onLowMemory(): Promise<any>;
410
424
  onDestroy(): Promise<any>;
425
+ project(data: LatLng): {
426
+ x: number;
427
+ y: number;
428
+ };
429
+ projectBack(screenCoordinate: {
430
+ x: number;
431
+ y: number;
432
+ }): LatLng;
411
433
  }
412
434
  export declare abstract class MapboxViewCommonBase extends ContentView implements MapboxViewApi {
413
435
  protected mapbox: MapboxApi;
@@ -441,6 +463,7 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
441
463
  changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
442
464
  forceUserLocationUpdate(location: any): void;
443
465
  trackUser(options: TrackUserOptions): Promise<any>;
466
+ getUserLocationCameraMode(): UserLocationCameraMode;
444
467
  addSource(id: string, options: AddSourceOptions): Promise<any>;
445
468
  updateSource(id: string, options: UpdateSourceOptions): Promise<any>;
446
469
  removeSource(id: string): Promise<any>;
@@ -470,6 +493,10 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
470
493
  x: number;
471
494
  y: number;
472
495
  };
496
+ projectBack(screenCoordinate: {
497
+ x: number;
498
+ y: number;
499
+ }): LatLng;
473
500
  }
474
501
  export declare const mapReadyProperty: Property<MapboxViewCommonBase, string>;
475
502
  export declare const zoomLevelProperty: Property<MapboxViewCommonBase, number>;
package/common.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ContentView, Property, Trace, booleanConverter } from '@nativescript/core';
2
2
  export * from './geo.utils';
3
- export * from './filter/filter-parser';
3
+ export * from './expression/expression-parser';
4
4
  export * from './layers/layer-factory';
5
5
  export * from './layers/parser/property-parser';
6
6
  export const MapboxTraceCategory = 'NativescriptMapbox';
@@ -158,6 +158,9 @@ export class MapboxViewCommonBase extends ContentView {
158
158
  trackUser(options) {
159
159
  return this.mapbox.trackUser(options, this.getNativeMapView());
160
160
  }
161
+ getUserLocationCameraMode() {
162
+ return this.mapbox.getUserLocationCameraMode(this.getNativeMapView());
163
+ }
161
164
  addSource(id, options) {
162
165
  return this.mapbox.addSource(id, options, this.getNativeMapView());
163
166
  }
@@ -236,6 +239,9 @@ export class MapboxViewCommonBase extends ContentView {
236
239
  project(data) {
237
240
  return this.mapbox && this.mapbox.project(data);
238
241
  }
242
+ projectBack(screenCoordinate) {
243
+ return this.mapbox && this.mapbox.projectBack(screenCoordinate);
244
+ }
239
245
  }
240
246
  export const mapReadyProperty = new Property({ name: 'mapReady' });
241
247
  mapReadyProperty.register(MapboxViewCommonBase);
@@ -1,4 +1,4 @@
1
- export declare class FilterParser {
1
+ export declare class ExpressionParser {
2
2
  static parseJson(json: any[]): com.mapbox.mapboxsdk.style.expressions.Expression;
3
3
  static toJson(filter: com.mapbox.mapboxsdk.style.expressions.Expression): any[];
4
4
  }
@@ -1,4 +1,4 @@
1
- export class FilterParser {
1
+ export class ExpressionParser {
2
2
  static parseJson(json) {
3
3
  const expression = com.mapbox.mapboxsdk.style.expressions.Expression.Converter.convert(JSON.stringify(json));
4
4
  return expression;
@@ -13,4 +13,4 @@ export class FilterParser {
13
13
  return JSON.parse(filter.toString());
14
14
  }
15
15
  }
16
- //# sourceMappingURL=filter-parser.android.js.map
16
+ //# sourceMappingURL=expression-parser.android.js.map
@@ -1,4 +1,4 @@
1
- export declare class FilterParser {
1
+ export declare class ExpressionParser {
2
2
  static parseJson(json: any[]): any;
3
3
  static toJson(filter: any): any[];
4
4
  }
@@ -1,4 +1,4 @@
1
- export declare class FilterParser {
1
+ export declare class ExpressionParser {
2
2
  static parseJson(json: any[]): NSPredicate;
3
3
  static toJson(filter: NSPredicate): any[];
4
4
  }
@@ -1,4 +1,4 @@
1
- export class FilterParser {
1
+ export class ExpressionParser {
2
2
  static parseJson(json) {
3
3
  const filterStr = NSString.stringWithString(JSON.stringify(json));
4
4
  const filterData = filterStr.dataUsingEncoding(NSUTF8StringEncoding);
@@ -19,4 +19,4 @@ export class FilterParser {
19
19
  return JSON.parse(expression);
20
20
  }
21
21
  }
22
- //# sourceMappingURL=filter-parser.ios.js.map
22
+ //# sourceMappingURL=expression-parser.ios.js.map
@@ -109,7 +109,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
109
109
  deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
110
110
  _getOfflineManager(): any;
111
111
  addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
112
- updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<unknown>;
112
+ updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<void>;
113
113
  addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
114
114
  removeSource(id: string, nativeMap?: any): Promise<void>;
115
115
  addLayer(style: any, belowLayerId?: string, nativeMap?: any): Promise<void>;
@@ -122,6 +122,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
122
122
  _getMapboxMapOptions(settings: any): com.mapbox.mapboxsdk.maps.MapboxMapOptions;
123
123
  _stringToCameraMode(mode: UserLocationCameraMode): any;
124
124
  _stringToRenderMode(mode: any): any;
125
+ _convertCameraMode(mode: any): UserLocationCameraMode;
125
126
  _fineLocationPermissionGranted(): boolean;
126
127
  _getRegionName(offlineRegion: com.mapbox.mapboxsdk.offline.OfflineRegion): string;
127
128
  _getRegionMetadata(offlineRegion: com.mapbox.mapboxsdk.offline.OfflineRegion): any;
@@ -138,4 +139,9 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
138
139
  x: number;
139
140
  y: number;
140
141
  };
142
+ projectBack(screenCoordinate: {
143
+ x: number;
144
+ y: number;
145
+ }): LatLng;
146
+ getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
141
147
  }
package/index.android.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { request } from '@nativescript-community/perms';
2
2
  import { AndroidApplication, Application, Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
3
- import { FilterParser } from './filter/filter-parser';
3
+ import { ExpressionParser } from './expression/expression-parser';
4
4
  import { Layer, LayerFactory } from './layers/layer-factory';
5
5
  import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
6
6
  export * from './common';
@@ -1085,7 +1085,7 @@ export class Mapbox extends MapboxCommon {
1085
1085
  const mapboxPoint = new com.mapbox.mapboxsdk.geometry.LatLng(options.point.lat, options.point.lng);
1086
1086
  const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
1087
1087
  if (this._mapboxMapInstance.queryRenderedFeatures) {
1088
- const queryFilter = options.filter ? FilterParser.parseJson(options.filter) : null;
1088
+ const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
1089
1089
  const features = this._mapboxMapInstance.queryRenderedFeatures(screenLocation, queryFilter, options.layers);
1090
1090
  const result = [];
1091
1091
  for (let i = 0; i < features.size(); i++) {
@@ -1117,7 +1117,7 @@ export class Mapbox extends MapboxCommon {
1117
1117
  throw new Error(`Source with id "${sourceId}" not found.`);
1118
1118
  }
1119
1119
  let features;
1120
- const queryFilter = options.filter ? FilterParser.parseJson(options.filter) : null;
1120
+ const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
1121
1121
  if (source instanceof com.mapbox.mapboxsdk.style.sources.GeoJsonSource) {
1122
1122
  features = source.querySourceFeatures(queryFilter);
1123
1123
  }
@@ -1786,6 +1786,7 @@ export class Mapbox extends MapboxCommon {
1786
1786
  case 'geojson':
1787
1787
  const geoJsonString = JSON.stringify(options.data);
1788
1788
  source.setGeoJson(geoJsonString);
1789
+ resolve();
1789
1790
  break;
1790
1791
  default:
1791
1792
  reject('Invalid source type: ' + options['type']);
@@ -1850,11 +1851,24 @@ export class Mapbox extends MapboxCommon {
1850
1851
  if (options.maxzoom) {
1851
1852
  geojsonOptions.withMaxZoom(options.maxzoom);
1852
1853
  }
1854
+ if (options.lineMetrics !== undefined) {
1855
+ geojsonOptions.withLineMetrics(options.lineMetrics);
1856
+ }
1853
1857
  if (options.cluster) {
1854
1858
  geojsonOptions
1855
1859
  .withCluster(true)
1856
1860
  .withClusterMaxZoom(options.cluster.maxZoom || 13)
1857
1861
  .withClusterRadius(options.cluster.radius || 40);
1862
+ if (options.cluster.properties) {
1863
+ for (const property of Object.keys(options.cluster.properties)) {
1864
+ const propertyValues = options.cluster.properties[property];
1865
+ let operator = propertyValues[0];
1866
+ if (!Array.isArray(operator)) {
1867
+ operator = [operator];
1868
+ }
1869
+ geojsonOptions.withClusterProperty(property, ExpressionParser.parseJson(operator), ExpressionParser.parseJson(propertyValues[1]));
1870
+ }
1871
+ }
1858
1872
  }
1859
1873
  const geoJsonSource = new com.mapbox.mapboxsdk.style.sources.GeoJsonSource(id, geojsonOptions);
1860
1874
  if (options.data) {
@@ -1961,7 +1975,7 @@ export class Mapbox extends MapboxCommon {
1961
1975
  if (!lineSource) {
1962
1976
  throw new Error(`no source found with id: ${sId}`);
1963
1977
  }
1964
- const lineFeatures = lineSource.querySourceFeatures(FilterParser.parseJson(['==', '$type', 'LineString']));
1978
+ const lineFeatures = lineSource.querySourceFeatures(ExpressionParser.parseJson(['==', '$type', 'LineString']));
1965
1979
  if (lineFeatures.size() === 0) {
1966
1980
  throw new Error('no line string feature found');
1967
1981
  }
@@ -2174,6 +2188,26 @@ export class Mapbox extends MapboxCommon {
2174
2188
  }
2175
2189
  return renderMode;
2176
2190
  }
2191
+ _convertCameraMode(mode) {
2192
+ const modeRef = com.mapbox.mapboxsdk.location.modes.CameraMode;
2193
+ switch (mode) {
2194
+ case modeRef.NONE:
2195
+ return "NONE";
2196
+ case modeRef.NONE_COMPASS:
2197
+ return "NONE_COMPASS";
2198
+ case modeRef.NONE_GPS:
2199
+ return "NONE_GPS";
2200
+ case modeRef.TRACKING:
2201
+ return "TRACKING";
2202
+ case modeRef.TRACKING_COMPASS:
2203
+ return "TRACKING_COMPASS";
2204
+ case modeRef.TRACKING_GPS:
2205
+ return "TRACKING_GPS";
2206
+ case modeRef.TRACKING_GPS_NORTH:
2207
+ return "TRACKING_GPS_NORTH";
2208
+ }
2209
+ return "NONE";
2210
+ }
2177
2211
  _fineLocationPermissionGranted() {
2178
2212
  let hasPermission = android.os.Build.VERSION.SDK_INT < 23;
2179
2213
  if (!hasPermission) {
@@ -2480,5 +2514,22 @@ export class Mapbox extends MapboxCommon {
2480
2514
  const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
2481
2515
  return { x: Utils.layout.toDeviceIndependentPixels(screenLocation.x), y: Utils.layout.toDeviceIndependentPixels(screenLocation.y) };
2482
2516
  }
2517
+ projectBack(screenCoordinate) {
2518
+ const pointf = new android.graphics.PointF(screenCoordinate.x, screenCoordinate.y);
2519
+ const coordinate = this._mapboxMapInstance.getProjection().fromScreenLocation(pointf);
2520
+ return {
2521
+ lat: coordinate.getLatitude(),
2522
+ lng: coordinate.getLongitude()
2523
+ };
2524
+ }
2525
+ getUserLocationCameraMode(nativeMap) {
2526
+ if (!this._mapboxMapInstance) {
2527
+ return "NONE";
2528
+ }
2529
+ if (!this._locationComponent) {
2530
+ return "NONE";
2531
+ }
2532
+ return this._convertCameraMode(this._locationComponent.getCameraMode());
2533
+ }
2483
2534
  }
2484
2535
  //# sourceMappingURL=index.android.js.map
package/index.d.ts CHANGED
@@ -97,4 +97,5 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
97
97
  x: number;
98
98
  y: number;
99
99
  };
100
- }
100
+ projectBack(screenCoordinate: { x: number, y: number }): LatLng;
101
+ }
package/index.ios.d.ts CHANGED
@@ -53,6 +53,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
53
53
  getUserLocation(nativeMap?: any): Promise<UserLocation>;
54
54
  _stringToCameraMode(mode: UserLocationCameraMode): any;
55
55
  _stringToRenderMode(mode: any): any;
56
+ _convertCameraMode(mode: MGLUserTrackingMode): UserLocationCameraMode;
56
57
  showUserLocationMarker(options: any, nativeMap?: any): Promise<void>;
57
58
  hideUserLocationMarker(nativeMap?: any): Promise<void>;
58
59
  changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
@@ -81,7 +82,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
81
82
  listOfflineRegions(options?: ListOfflineRegionsOptions): Promise<OfflineRegion[]>;
82
83
  deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
83
84
  addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
84
- updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<unknown>;
85
+ updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<void>;
85
86
  addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
86
87
  removeSource(id: string, nativeMap?: any): Promise<void>;
87
88
  addLayer(style: any, belowLayerId?: string, nativeMapView?: any): Promise<void>;
@@ -95,4 +96,9 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
95
96
  x: number;
96
97
  y: number;
97
98
  };
99
+ projectBack(screenCoordinate: {
100
+ x: number;
101
+ y: number;
102
+ }): LatLng;
103
+ getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
98
104
  }
package/index.ios.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
2
2
  import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
3
3
  import { Layer, LayerFactory } from './layers/layer-factory';
4
- import { FilterParser } from './filter/filter-parser';
4
+ import { ExpressionParser } from './expression/expression-parser';
5
5
  var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
6
6
  __extends(MGLMapViewDelegateImpl, _super);
7
7
  function MGLMapViewDelegateImpl() {
@@ -463,9 +463,6 @@ const _getMapStyle = (input) => {
463
463
  return MGLStyle.streetsStyleURL;
464
464
  }
465
465
  };
466
- function _getTrackingMode(input) {
467
- return 0;
468
- }
469
466
  function _getLocation(loc) {
470
467
  if (loc === null) {
471
468
  return null;
@@ -1333,27 +1330,26 @@ export class Mapbox extends MapboxCommon {
1333
1330
  }
1334
1331
  _stringToCameraMode(mode) {
1335
1332
  switch (mode) {
1336
- case 'NONE':
1333
+ case "NONE":
1337
1334
  return 0;
1338
- case 'NONE_COMPASS':
1339
- if (Trace.isEnabled()) {
1340
- CLog(CLogTypes.info, '_stringToCameraMode(): NONE_COMPASS unsupported on iOS');
1341
- }
1335
+ case "NONE_COMPASS":
1336
+ console.log("MapboxView::_stringToCameraMode(): NONE_COMPASS unsupported on iOS");
1342
1337
  return 0;
1343
- case 'NONE_GPS':
1344
- if (Trace.isEnabled()) {
1345
- CLog(CLogTypes.info, '_stringToCameraMode(): NONE_GPS unsupported on iOS');
1346
- }
1338
+ case "NONE_GPS":
1339
+ console.log("MapboxView::_stringToCameraMode(): NONE_GPS unsupported on iOS");
1347
1340
  return 0;
1348
- case 'TRACKING':
1341
+ case "TRACKING":
1349
1342
  return 1;
1350
- case 'TRACKING_COMPASS':
1343
+ case "TRACKING_COMPASS":
1351
1344
  return 2;
1352
- case 'TRACKING_GPS':
1345
+ case "TRACKING_GPS":
1353
1346
  return 1;
1354
- case 'TRACKING_GPS_NORTH':
1347
+ case "TRACKING_GPS_NORTH":
1355
1348
  return 3;
1349
+ default:
1350
+ console.log(`_stringToCameraMode: invalid cameraMode: ${mode}`);
1356
1351
  }
1352
+ return 0;
1357
1353
  }
1358
1354
  _stringToRenderMode(mode) {
1359
1355
  let renderMode;
@@ -1366,6 +1362,18 @@ export class Mapbox extends MapboxCommon {
1366
1362
  return 'GPS';
1367
1363
  }
1368
1364
  }
1365
+ _convertCameraMode(mode) {
1366
+ switch (mode) {
1367
+ case 0:
1368
+ return "NONE";
1369
+ case 1:
1370
+ return "TRACKING";
1371
+ case 2:
1372
+ return "TRACKING_COMPASS";
1373
+ case 3:
1374
+ return "TRACKING_GPS_NORTH";
1375
+ }
1376
+ }
1369
1377
  showUserLocationMarker(options, nativeMap) {
1370
1378
  return new Promise((resolve, reject) => {
1371
1379
  try {
@@ -1436,7 +1444,7 @@ export class Mapbox extends MapboxCommon {
1436
1444
  }
1437
1445
  const { x, y } = theMap.convertCoordinateToPointToView({ latitude: options.point.lat, longitude: options.point.lng }, theMap);
1438
1446
  const queryLayerIds = options.layers ? NSSet.setWithArray(Utils.ios.collections.jsArrayToNSArray(options.layers)) : null;
1439
- const queryFilter = options.filter ? FilterParser.parseJson(options.filter) : null;
1447
+ const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
1440
1448
  const features = theMap.visibleFeaturesAtPointInStyleLayersWithIdentifiersPredicate({ x, y }, queryLayerIds, queryFilter);
1441
1449
  const result = [];
1442
1450
  for (let i = 0; i < features.count; i++) {
@@ -1466,7 +1474,7 @@ export class Mapbox extends MapboxCommon {
1466
1474
  throw new Error(`Source with id "${sourceId}" not found.`);
1467
1475
  }
1468
1476
  let features;
1469
- const queryFilter = options.filter ? FilterParser.parseJson(options.filter) : null;
1477
+ const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
1470
1478
  if (source instanceof MGLShapeSource) {
1471
1479
  features = source.featuresMatchingPredicate(queryFilter);
1472
1480
  }
@@ -2059,6 +2067,7 @@ export class Mapbox extends MapboxCommon {
2059
2067
  const nsData = content.dataUsingEncoding(NSUTF8StringEncoding);
2060
2068
  const geoJsonShape = MGLShape.shapeWithDataEncodingError(nsData, NSUTF8StringEncoding);
2061
2069
  source.shape = geoJsonShape;
2070
+ resolve();
2062
2071
  break;
2063
2072
  default:
2064
2073
  reject('Invalid source type: ' + options['type']);
@@ -2139,10 +2148,25 @@ export class Mapbox extends MapboxCommon {
2139
2148
  if (options.maxzoom !== undefined) {
2140
2149
  sourceOptions[MGLShapeSourceOptionMaximumZoomLevel] = options.maxzoom;
2141
2150
  }
2151
+ if (options.lineMetrics !== undefined) {
2152
+ sourceOptions[MGLShapeSourceOptionLineDistanceMetrics] = options.lineMetrics;
2153
+ }
2142
2154
  if (options.cluster) {
2143
2155
  sourceOptions[MGLShapeSourceOptionClustered] = true;
2144
2156
  sourceOptions[MGLShapeSourceOptionClusterRadius] = options.cluster.radius || 40;
2145
2157
  sourceOptions[MGLShapeSourceOptionMaximumZoomLevelForClustering] = options.cluster.maxZoom || 13;
2158
+ if (options.cluster.properties) {
2159
+ const clusterProperties = {};
2160
+ for (const property of Object.keys(options.cluster.properties)) {
2161
+ let [operator, operand] = options.cluster.properties[property];
2162
+ if (!Array.isArray(operator)) {
2163
+ operator = [operator];
2164
+ }
2165
+ const expressions = Utils.ios.collections.jsArrayToNSArray([ExpressionParser.parseJson(operator), ExpressionParser.parseJson(operand)]);
2166
+ clusterProperties[property] = expressions;
2167
+ }
2168
+ sourceOptions[MGLShapeSourceOptionClusterProperties] = clusterProperties;
2169
+ }
2146
2170
  }
2147
2171
  source = MGLShapeSource.alloc().initWithIdentifierShapeOptions(id, geoJsonShape, sourceOptions);
2148
2172
  break;
@@ -2269,7 +2293,7 @@ export class Mapbox extends MapboxCommon {
2269
2293
  throw new Error(`no source found with id: ${sId}`);
2270
2294
  }
2271
2295
  try {
2272
- const lineFeatures = lineSource.featuresMatchingPredicate(FilterParser.parseJson(['==', '$type', 'LineString']));
2296
+ const lineFeatures = lineSource.featuresMatchingPredicate(ExpressionParser.parseJson(['==', '$type', 'LineString']));
2273
2297
  if (lineFeatures.count === 0) {
2274
2298
  throw new Error('no line string feature found');
2275
2299
  }
@@ -2299,7 +2323,7 @@ export class Mapbox extends MapboxCommon {
2299
2323
  reject('The map is not currently showing the user location');
2300
2324
  return;
2301
2325
  }
2302
- theMap.setUserTrackingModeAnimated(_getTrackingMode(options.cameraMode), options.animated !== false);
2326
+ theMap.setUserTrackingModeAnimated(this._stringToCameraMode(options.cameraMode), options.animated !== false);
2303
2327
  resolve();
2304
2328
  }
2305
2329
  catch (ex) {
@@ -2357,6 +2381,25 @@ export class Mapbox extends MapboxCommon {
2357
2381
  const { x, y } = theMap.convertCoordinateToPointToView({ latitude: data.lat, longitude: data.lng }, theMap);
2358
2382
  return { x, y };
2359
2383
  }
2384
+ projectBack(screenCoordinate) {
2385
+ const theMap = this._mapboxViewInstance;
2386
+ const cgPoint = {
2387
+ x: screenCoordinate.x,
2388
+ y: screenCoordinate.y
2389
+ };
2390
+ const coordinate = theMap.convertPointToCoordinateFromView(cgPoint, theMap);
2391
+ return {
2392
+ lat: coordinate.latitude,
2393
+ lng: coordinate.longitude
2394
+ };
2395
+ }
2396
+ getUserLocationCameraMode(nativeMap) {
2397
+ let theMap = nativeMap || this._mapboxViewInstance;
2398
+ if (!theMap) {
2399
+ return "NONE";
2400
+ }
2401
+ return this._convertCameraMode(theMap.userTrackingMode);
2402
+ }
2360
2403
  }
2361
2404
  const _addObserver = (eventName, callback) => NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(eventName, null, NSOperationQueue.mainQueue, callback);
2362
2405
  function _downloadImage(marker) {
@@ -1,4 +1,4 @@
1
- import { LayerCommon } from '../common';
1
+ import { LayerCommon, LayerType } from "../common";
2
2
  export declare class Layer implements LayerCommon {
3
3
  id: string;
4
4
  private instance;
@@ -11,6 +11,7 @@ export declare class Layer implements LayerCommon {
11
11
  getFilter(): any[];
12
12
  setProperty(name: string, value: any): void;
13
13
  getProperty(name: string): any;
14
+ type(): LayerType;
14
15
  }
15
16
  export declare class LayerFactory {
16
17
  static createLayer(style: any, source: any): Promise<LayerCommon>;
@@ -1,4 +1,4 @@
1
- import { FilterParser } from '../filter/filter-parser';
1
+ import { ExpressionParser } from '../expression/expression-parser';
2
2
  import { PropertyParser } from './parser/property-parser';
3
3
  export class Layer {
4
4
  constructor(instance) {
@@ -18,10 +18,10 @@ export class Layer {
18
18
  return this.instance;
19
19
  }
20
20
  setFilter(filter) {
21
- this.instance.setFilter(FilterParser.parseJson(filter));
21
+ this.instance.setFilter(ExpressionParser.parseJson(filter));
22
22
  }
23
23
  getFilter() {
24
- return FilterParser.toJson(this.instance.getFilter());
24
+ return ExpressionParser.toJson(this.instance.getFilter());
25
25
  }
26
26
  setProperty(name, value) {
27
27
  const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
@@ -30,6 +30,36 @@ export class Layer {
30
30
  getProperty(name) {
31
31
  return PropertyParser.propertyValueFromLayer(this.instance, name);
32
32
  }
33
+ type() {
34
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillLayer) {
35
+ return "fill";
36
+ }
37
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.LineLayer) {
38
+ return "line";
39
+ }
40
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.SymbolLayer) {
41
+ return "symbol";
42
+ }
43
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.CircleLayer) {
44
+ return "circle";
45
+ }
46
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.HeatmapLayer) {
47
+ return "heatmap";
48
+ }
49
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer) {
50
+ return "fill-extrusion";
51
+ }
52
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.RasterLayer) {
53
+ return "raster";
54
+ }
55
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.HillshadeLayer) {
56
+ return "hillshade";
57
+ }
58
+ if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.BackgroundLayer) {
59
+ return "background";
60
+ }
61
+ return null;
62
+ }
33
63
  }
34
64
  export class LayerFactory {
35
65
  static async createLayer(style, source) {
@@ -1,4 +1,4 @@
1
- import { LayerCommon } from '../common';
1
+ import { LayerCommon, LayerType } from "../common"
2
2
 
3
3
  declare class LayerFactory {
4
4
  static createLayer(style, source): Promise<LayerCommon>;
@@ -16,4 +16,5 @@ export declare class Layer implements LayerCommon {
16
16
  getFilter(): any[];
17
17
  setProperty(name: string, value: any): void;
18
18
  getProperty(name: string): any;
19
- }
19
+ type(): LayerType;
20
+ }
@@ -1,4 +1,4 @@
1
- import { LayerCommon } from '../common';
1
+ import { LayerCommon, LayerType } from "../common";
2
2
  export declare class LayerFactory {
3
3
  static createLayer(style: any, source: any): Promise<LayerCommon>;
4
4
  private static parseProperties;
@@ -6,7 +6,8 @@ export declare class LayerFactory {
6
6
  export declare class Layer implements LayerCommon {
7
7
  id: string;
8
8
  private instance;
9
- constructor(instance: any);
9
+ constructor(instance: MGLStyleLayer);
10
+ type(): LayerType;
10
11
  visibility(): boolean;
11
12
  show(): void;
12
13
  hide(): void;
@@ -1,4 +1,4 @@
1
- import { FilterParser } from '../filter/filter-parser';
1
+ import { ExpressionParser } from '../expression/expression-parser';
2
2
  import { PropertyParser } from './parser/property-parser';
3
3
  export class LayerFactory {
4
4
  static async createLayer(style, source) {
@@ -49,6 +49,36 @@ export class Layer {
49
49
  this.instance = instance;
50
50
  this.id = instance.identifier;
51
51
  }
52
+ type() {
53
+ if (this.instance instanceof MGLFillStyleLayer) {
54
+ return "fill";
55
+ }
56
+ if (this.instance instanceof MGLLineStyleLayer) {
57
+ return "line";
58
+ }
59
+ if (this.instance instanceof MGLSymbolStyleLayer) {
60
+ return "symbol";
61
+ }
62
+ if (this.instance instanceof MGLCircleStyleLayer) {
63
+ return "circle";
64
+ }
65
+ if (this.instance instanceof MGLHeatmapStyleLayer) {
66
+ return "heatmap";
67
+ }
68
+ if (this.instance instanceof MGLFillExtrusionStyleLayer) {
69
+ return "fill-extrusion";
70
+ }
71
+ if (this.instance instanceof MGLRasterStyleLayer) {
72
+ return "raster";
73
+ }
74
+ if (this.instance instanceof MGLHillshadeStyleLayer) {
75
+ return "hillshade";
76
+ }
77
+ if (this.instance instanceof MGLBackgroundStyleLayer) {
78
+ return "background";
79
+ }
80
+ return null;
81
+ }
52
82
  visibility() {
53
83
  return this.instance.visible;
54
84
  }
@@ -63,14 +93,14 @@ export class Layer {
63
93
  }
64
94
  setFilter(filter) {
65
95
  if (this.instance instanceof MGLVectorStyleLayer) {
66
- this.instance.predicate = FilterParser.parseJson(filter);
96
+ this.instance.predicate = ExpressionParser.parseJson(filter);
67
97
  }
68
98
  else {
69
99
  throw new Error('Set filter only support for vector layer.');
70
100
  }
71
101
  }
72
102
  getFilter() {
73
- return FilterParser.toJson(this.instance.predicate);
103
+ return ExpressionParser.toJson(this.instance.predicate);
74
104
  }
75
105
  setProperty(name, value) {
76
106
  const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-mapbox",
3
- "version": "6.2.12",
3
+ "version": "6.2.15",
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.2.0"
56
56
  },
57
- "gitHead": "44fe8fec4a1d5ddfcd529919346f238afecabc94"
57
+ "gitHead": "0fcc83da4bd587591485042c0cec891041d9049a"
58
58
  }
@@ -2661,6 +2661,8 @@ declare var MGLShapeSourceOptionClusterRadius: string;
2661
2661
 
2662
2662
  declare var MGLShapeSourceOptionClustered: string;
2663
2663
 
2664
+ declare var MGLShapeSourceOptionClusterProperties: string;
2665
+
2664
2666
  declare var MGLShapeSourceOptionLineDistanceMetrics: string;
2665
2667
 
2666
2668
  declare var MGLShapeSourceOptionMaximumZoomLevel: string;