@nativescript-community/ui-mapbox 6.2.31 → 7.0.0-alpha.14.3191a7b

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/index.d.ts CHANGED
@@ -1,5 +1,36 @@
1
1
  import { ImageSource } from '@nativescript/core';
2
- import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, MapStyle, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport } from './common';
2
+ import {
3
+ AddExtrusionOptions,
4
+ AddGeoJsonClusteredOptions,
5
+ AddPolygonOptions,
6
+ AddPolylineOptions,
7
+ AddSourceOptions,
8
+ AnimateCameraOptions,
9
+ DeleteOfflineRegionOptions,
10
+ DownloadOfflineRegionOptions,
11
+ Feature,
12
+ LatLng,
13
+ LayerCommon,
14
+ ListOfflineRegionsOptions,
15
+ MapStyle,
16
+ MapboxApi,
17
+ MapboxCommon,
18
+ MapboxMarker,
19
+ MapboxViewBase,
20
+ OfflineRegion,
21
+ QueryRenderedFeaturesOptions,
22
+ QuerySourceFeaturesOptions,
23
+ SetCenterOptions,
24
+ SetTiltOptions,
25
+ SetViewportOptions,
26
+ SetZoomLevelOptions,
27
+ ShowOptions,
28
+ TrackUserOptions,
29
+ UpdateSourceOptions,
30
+ UserLocation,
31
+ UserLocationCameraMode,
32
+ Viewport
33
+ } from './common';
3
34
 
4
35
  // Export any shared classes, constants, etc.
5
36
  export * from './common';
@@ -13,7 +44,7 @@ export declare class MapboxView extends MapboxViewBase {
13
44
  private initCountHack;
14
45
  setConfig(settings: any): void;
15
46
  getNativeMapView(): any;
16
- createNativeView(): Object;
47
+ createNativeView(): object;
17
48
  onLoaded(): void;
18
49
  initNativeView(): void;
19
50
  disposeNativeView(): Promise<void>;
@@ -58,7 +89,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
58
89
  _stringToRenderMode(mode: any): any;
59
90
  showUserLocationMarker(options: any, nativeMap?: any): Promise<void>;
60
91
  hideUserLocationMarker(nativeMap?: any): Promise<void>;
61
- changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
92
+ // changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
62
93
  forceUserLocationUpdate(location: any, nativeMap?: any): void;
63
94
  queryRenderedFeatures(options: QueryRenderedFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
64
95
  querySourceFeatures(sourceId: string, options?: QuerySourceFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
@@ -76,7 +107,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
76
107
  setOnFlingListener(listener: () => void, nativeMap?: any): Promise<void>;
77
108
  setOnCameraMoveListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
78
109
  setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<void>;
79
- setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
110
+ setOnMapIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
80
111
  getViewport(nativeMap?: any): Promise<Viewport>;
81
112
  setViewport(options: SetViewportOptions, nativeMap?: any): Promise<void>;
82
113
  downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<void>;
@@ -97,5 +128,5 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
97
128
  x: number;
98
129
  y: number;
99
130
  };
100
- projectBack(screenCoordinate: { x: number, y: number }): LatLng;
131
+ projectBack(screenCoordinate: { x: number; y: number }): LatLng;
101
132
  }
package/index.ios.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ImageSource } from '@nativescript/core';
2
- import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapStyle, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport } from './common';
2
+ import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapStyle, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport, telemetryProperty } from './common';
3
3
  export * from './common';
4
4
  export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' | 'fault' | 'verbose'): void;
5
5
  /**
@@ -9,8 +9,10 @@ export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' |
9
9
  * code.
10
10
  */
11
11
  export declare class MapboxView extends MapboxViewBase {
12
+ [telemetryProperty.setNative]: (value: boolean) => void;
12
13
  private nativeMapView;
13
14
  private delegate;
15
+ mapbox: Mapbox;
14
16
  private settings;
15
17
  private initialized;
16
18
  private initCountHack;
@@ -19,7 +21,7 @@ export declare class MapboxView extends MapboxViewBase {
19
21
  */
20
22
  setConfig(settings: any): void;
21
23
  getNativeMapView(): any;
22
- createNativeView(): Object;
24
+ createNativeView(): object;
23
25
  /**
24
26
  * init the native view.
25
27
  *
@@ -197,9 +199,9 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
197
199
  setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
198
200
  setOnMoveEndListener(listener: () => void, nativeMap?: any): Promise<void>;
199
201
  setOnFlingListener(listener: () => void, nativeMap?: any): Promise<void>;
200
- setOnCameraMoveListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
202
+ setOnCameraChangeListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
201
203
  setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<void>;
202
- setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
204
+ setOnMapIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
203
205
  getViewport(nativeMap?: any): Promise<Viewport>;
204
206
  setViewport(options: SetViewportOptions, nativeMap?: any): Promise<void>;
205
207
  downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<void>;
package/index.ios.js CHANGED
@@ -123,7 +123,7 @@ var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
123
123
  };
124
124
  MGLMapViewDelegateImpl.prototype.mapViewDidFailLoadingMapWithError = function (mapView, error) {
125
125
  if (Trace.isEnabled()) {
126
- CLog(CLogTypes.info, 'mapViewDidFailLoadingMapWithError: ' + error);
126
+ CLog(CLogTypes.info, 'mapViewDidFailLoadingMapWithError: ' + error.localizedDescription);
127
127
  }
128
128
  };
129
129
  MGLMapViewDelegateImpl.prototype.mapViewDidChangeUserTrackingModeAnimated = function (mapView, mode, animated) {
@@ -218,8 +218,7 @@ var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
218
218
  }
219
219
  };
220
220
  MGLMapViewDelegateImpl.prototype.getTappedMarkerDetails = function (tapped) {
221
- for (var m in _markers) {
222
- var cached = _markers[m];
221
+ _markers.forEach(function (cached) {
223
222
  // don't compare lat/lng types as they're not the same (same for (sub)title, they may be null vs undefined)
224
223
  if (
225
224
  // eslint-disable-next-line eqeqeq
@@ -232,7 +231,7 @@ var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
232
231
  cached.subtitle == tapped.subtitle) {
233
232
  return cached;
234
233
  }
235
- }
234
+ });
236
235
  };
237
236
  MGLMapViewDelegateImpl.prototype.mapViewRegionIsChangingWithReason = function (mapView, reason) {
238
237
  if (Trace.isEnabled()) {
@@ -1063,7 +1062,7 @@ export class Mapbox extends MapboxCommon {
1063
1062
  }
1064
1063
  catch (ex) {
1065
1064
  if (Trace.isEnabled()) {
1066
- CLog(CLogTypes.info, 'Error in mapbox.addMarkers: ' + ex);
1065
+ CLog(CLogTypes.error, 'Error in mapbox.addMarkers: ' + ex);
1067
1066
  }
1068
1067
  reject(ex);
1069
1068
  }
@@ -1566,7 +1565,7 @@ export class Mapbox extends MapboxCommon {
1566
1565
  if (options.bounds) {
1567
1566
  const padding = options.padding || 0;
1568
1567
  // 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
+ const { bottom = 0, left = 0, right = 0, top = 0 } = typeof padding === 'object' ? padding : { top: padding, left: padding, bottom: padding, right: padding };
1570
1569
  // support defined padding
1571
1570
  const insets = { top, left, bottom, right };
1572
1571
  const bounds = {
@@ -1778,7 +1777,7 @@ export class Mapbox extends MapboxCommon {
1778
1777
  // there's no swipe event we can bind to
1779
1778
  return Promise.reject("'setOnFlingListener' is not supported on iOS");
1780
1779
  }
1781
- async setOnCameraMoveListener(listener, nativeMap) {
1780
+ async setOnCameraChangeListener(listener, nativeMap) {
1782
1781
  const theMap = nativeMap || this._mapboxViewInstance;
1783
1782
  if (theMap) {
1784
1783
  theMap.delegate.setCameraChangedListener(listener);
@@ -1790,7 +1789,7 @@ export class Mapbox extends MapboxCommon {
1790
1789
  setOnCameraMoveCancelListener(listener, nativeMap) {
1791
1790
  return Promise.reject("'setOnCameraMoveCancelListener' not currently supported on iOS");
1792
1791
  }
1793
- async setOnCameraIdleListener(listener, nativeMap) {
1792
+ async setOnMapIdleListener(listener, nativeMap) {
1794
1793
  const theMap = nativeMap || this._mapboxViewInstance;
1795
1794
  if (theMap) {
1796
1795
  theMap.delegate.setCameraIdledListener(listener);
@@ -1960,7 +1959,7 @@ export class Mapbox extends MapboxCommon {
1960
1959
  const userInfo = NSKeyedUnarchiver.unarchiveObjectWithData(pack.context);
1961
1960
  regions.push({
1962
1961
  name: userInfo.objectForKey('name'),
1963
- style: '' + region.styleURL,
1962
+ style: region.styleURL.absoluteString,
1964
1963
  minZoom: region.minimumZoomLevel,
1965
1964
  maxZoom: region.maximumZoomLevel,
1966
1965
  bounds: {
@@ -1,12 +1,13 @@
1
- import { LayerCommon, LayerType } from "../common";
1
+ import { LayerCommon, LayerType } from '../common';
2
+ type ILayer = com.mapbox.maps.extension.style.layers.generated.FillLayer | com.mapbox.maps.extension.style.layers.generated.LineLayer | com.mapbox.maps.extension.style.layers.generated.SymbolLayer | com.mapbox.maps.extension.style.layers.generated.CircleLayer | com.mapbox.maps.extension.style.layers.generated.HeatmapLayer | com.mapbox.maps.extension.style.layers.generated.FillExtrusionLayer | com.mapbox.maps.extension.style.layers.generated.RasterLayer | com.mapbox.maps.extension.style.layers.generated.HillshadeLayer;
2
3
  export declare class Layer implements LayerCommon {
3
4
  id: string;
4
5
  private instance;
5
- constructor(instance: any);
6
+ constructor(instance: ILayer);
6
7
  visibility(): boolean;
7
8
  show(): void;
8
9
  hide(): void;
9
- getNativeInstance(): any;
10
+ getNativeInstance(): ILayer;
10
11
  setFilter(filter: any[]): void;
11
12
  getFilter(): any[];
12
13
  setProperty(name: string, value: any): void;
@@ -14,6 +15,7 @@ export declare class Layer implements LayerCommon {
14
15
  type(): LayerType;
15
16
  }
16
17
  export declare class LayerFactory {
17
- static createLayer(style: any, source: any): Promise<LayerCommon>;
18
- private static parseProperties;
18
+ static applyLayerProperties(layer: com.mapbox.maps.extension.style.layers.Layer, properties: Record<string, any>): void;
19
+ static createLayer(style: any, source: com.mapbox.maps.extension.style.sources.Source): Promise<LayerCommon>;
19
20
  }
21
+ export {};
@@ -1,105 +1,135 @@
1
1
  import { ExpressionParser } from '../expression/expression-parser';
2
2
  import { PropertyParser } from './parser/property-parser';
3
+ import { toCamelCase, transformValue } from './parser/property-parser.android';
3
4
  export class Layer {
4
5
  constructor(instance) {
5
6
  this.instance = instance;
6
- this.id = instance.getId();
7
+ this.id = instance.getSourceId();
7
8
  }
8
9
  visibility() {
9
10
  return this.instance.getVisibility().getValue() === 'visible' ? true : false;
10
11
  }
11
12
  show() {
12
- this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'visible')]);
13
+ LayerFactory.applyLayerProperties(this.instance, {
14
+ visibility: 'visible'
15
+ });
16
+ // this.instance.setProperties([new com.mapbox.maps.extension.style.layers.generated.PropertyValue('visibility', 'visible')]);
13
17
  }
14
18
  hide() {
15
- this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'none')]);
19
+ LayerFactory.applyLayerProperties(this.instance, {
20
+ visibility: 'none'
21
+ });
22
+ // this.instance.setProperties([new com.mapbox.maps.extension.style.layers.generated.PropertyValue('visibility', 'none')]);
16
23
  }
17
24
  getNativeInstance() {
18
25
  return this.instance;
19
26
  }
20
27
  setFilter(filter) {
21
- this.instance.setFilter(ExpressionParser.parseJson(filter));
28
+ if (this.instance['setFilter']) {
29
+ this.instance['setFilter'](ExpressionParser.parseJson(filter));
30
+ }
22
31
  }
23
32
  getFilter() {
24
- return ExpressionParser.toJson(this.instance.getFilter());
33
+ if (this.instance['getFilter']) {
34
+ return ExpressionParser.toJson(this.instance['getFilter']());
35
+ }
36
+ return [];
25
37
  }
26
38
  setProperty(name, value) {
27
- const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
28
- this.instance.setProperties(properties);
39
+ LayerFactory.applyLayerProperties(this.instance, {
40
+ [name]: value
41
+ });
29
42
  }
30
43
  getProperty(name) {
31
44
  return PropertyParser.propertyValueFromLayer(this.instance, name);
32
45
  }
33
46
  type() {
34
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillLayer) {
35
- return "fill";
47
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.FillLayer) {
48
+ return 'fill';
36
49
  }
37
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.LineLayer) {
38
- return "line";
50
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.LineLayer) {
51
+ return 'line';
39
52
  }
40
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.SymbolLayer) {
41
- return "symbol";
53
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.SymbolLayer) {
54
+ return 'symbol';
42
55
  }
43
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.CircleLayer) {
44
- return "circle";
56
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.CircleLayer) {
57
+ return 'circle';
45
58
  }
46
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.HeatmapLayer) {
47
- return "heatmap";
59
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.HeatmapLayer) {
60
+ return 'heatmap';
48
61
  }
49
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer) {
50
- return "fill-extrusion";
62
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.FillExtrusionLayer) {
63
+ return 'fill-extrusion';
51
64
  }
52
- if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.RasterLayer) {
53
- return "raster";
65
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.RasterLayer) {
66
+ return 'raster';
54
67
  }
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";
68
+ if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.HillshadeLayer) {
69
+ return 'hillshade';
60
70
  }
71
+ // if (this.instance instanceof com.mapbox.maps.extension.style.layers.generated.BackgroundLayer) {
72
+ // return 'background';
73
+ // }
61
74
  // there is no sky layer in the Android Mapbox SDK
62
75
  return null;
63
76
  }
64
77
  }
65
78
  export class LayerFactory {
79
+ static applyLayerProperties(layer, properties) {
80
+ for (const key in properties) {
81
+ if (!properties.hasOwnProperty(key))
82
+ continue;
83
+ const value = properties[key];
84
+ const actualKey = toCamelCase(key);
85
+ const nValue = transformValue(actualKey, value);
86
+ // Mapbox v11 setters are named after the property, e.g., circleColor(), circleRadius()
87
+ const setterName = actualKey;
88
+ // Call the setter dynamically
89
+ if (typeof layer[setterName] === 'function') {
90
+ layer[setterName](nValue);
91
+ }
92
+ else {
93
+ console.warn(`Layer has no setter for ${setterName}`);
94
+ }
95
+ }
96
+ }
66
97
  static async createLayer(style, source) {
67
- const layerProperties = this.parseProperties(style.type, Object.assign(style.paint || {}, style.layout || {})); // TODO: handle defaults
68
- const sourceId = source.getId();
98
+ // const layerProperties = this.parseProperties(style.type, Object.assign(style.paint || {}, style.layout || {})); // TODO: handle defaults
99
+ const layerProperties = Object.assign(style.paint || {}, style.layout || {}); // TODO: handle defaults
100
+ const sourceId = source.getSourceId();
69
101
  let nativeLayer;
70
102
  switch (style.type) {
71
103
  case 'line':
72
- nativeLayer = new com.mapbox.mapboxsdk.style.layers.LineLayer(style.id, sourceId).withProperties(layerProperties);
104
+ nativeLayer = new com.mapbox.maps.extension.style.layers.generated.LineLayer(style.id, sourceId);
73
105
  break;
74
106
  case 'circle':
75
- nativeLayer = new com.mapbox.mapboxsdk.style.layers.CircleLayer(style.id, sourceId).withProperties(layerProperties);
107
+ nativeLayer = new com.mapbox.maps.extension.style.layers.generated.CircleLayer(style.id, sourceId);
76
108
  break;
77
109
  case 'fill':
78
- nativeLayer = new com.mapbox.mapboxsdk.style.layers.FillLayer(style.id, sourceId).withProperties(layerProperties);
110
+ nativeLayer = new com.mapbox.maps.extension.style.layers.generated.FillLayer(style.id, sourceId);
79
111
  break;
80
112
  case 'symbol':
81
- nativeLayer = new com.mapbox.mapboxsdk.style.layers.SymbolLayer(style.id, sourceId).withProperties(layerProperties);
113
+ nativeLayer = new com.mapbox.maps.extension.style.layers.generated.SymbolLayer(style.id, sourceId);
82
114
  break;
83
115
  case 'raster':
84
- nativeLayer = new com.mapbox.mapboxsdk.style.layers.RasterLayer(style.id, sourceId).withProperties(layerProperties);
116
+ nativeLayer = new com.mapbox.maps.extension.style.layers.generated.RasterLayer(style.id, sourceId);
85
117
  break;
86
118
  default:
87
119
  throw new Error(`Unknown layer type: ${style.type}`);
88
120
  }
121
+ LayerFactory.applyLayerProperties(nativeLayer, layerProperties);
89
122
  const layer = new Layer(nativeLayer);
90
123
  if (style.minzoom !== undefined) {
91
- nativeLayer.setMinZoom(style.minzoom);
124
+ nativeLayer.minZoom(style.minzoom);
92
125
  }
93
126
  if (style.maxzoom !== undefined) {
94
- nativeLayer.setMaxZoom(style.maxzoom);
95
- }
96
- if (style['source-layer'] && nativeLayer.withSourceLayer) {
97
- nativeLayer.withSourceLayer(style['source-layer']);
127
+ nativeLayer.maxZoom(style.maxzoom);
98
128
  }
129
+ // if (style['source-layer'] && (nativeLayer as any).withSourceLayer) {
130
+ // (nativeLayer as any).withSourceLayer(style['source-layer']);
131
+ // }
99
132
  return layer;
100
133
  }
101
- static parseProperties(layerType, propertiesObject) {
102
- return PropertyParser.parsePropertiesForLayer(propertiesObject);
103
- }
104
134
  }
105
135
  //# sourceMappingURL=layer-factory.android.js.map
@@ -1,7 +1,8 @@
1
- import { LayerCommon, LayerType } from "../common"
1
+ import { LayerCommon, LayerType } from '../common';
2
2
 
3
3
  declare class LayerFactory {
4
4
  static createLayer(style, source): Promise<LayerCommon>;
5
+ static applyLayerProperties(layer: any, properties: Record<string, any>);
5
6
  }
6
7
 
7
8
  export declare class Layer implements LayerCommon {
@@ -1,4 +1,4 @@
1
- import { LayerCommon, LayerType } 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;
@@ -51,31 +51,31 @@ export class Layer {
51
51
  }
52
52
  type() {
53
53
  if (this.instance instanceof MGLFillStyleLayer) {
54
- return "fill";
54
+ return 'fill';
55
55
  }
56
56
  if (this.instance instanceof MGLLineStyleLayer) {
57
- return "line";
57
+ return 'line';
58
58
  }
59
59
  if (this.instance instanceof MGLSymbolStyleLayer) {
60
- return "symbol";
60
+ return 'symbol';
61
61
  }
62
62
  if (this.instance instanceof MGLCircleStyleLayer) {
63
- return "circle";
63
+ return 'circle';
64
64
  }
65
65
  if (this.instance instanceof MGLHeatmapStyleLayer) {
66
- return "heatmap";
66
+ return 'heatmap';
67
67
  }
68
68
  if (this.instance instanceof MGLFillExtrusionStyleLayer) {
69
- return "fill-extrusion";
69
+ return 'fill-extrusion';
70
70
  }
71
71
  if (this.instance instanceof MGLRasterStyleLayer) {
72
- return "raster";
72
+ return 'raster';
73
73
  }
74
74
  if (this.instance instanceof MGLHillshadeStyleLayer) {
75
- return "hillshade";
75
+ return 'hillshade';
76
76
  }
77
77
  if (this.instance instanceof MGLBackgroundStyleLayer) {
78
- return "background";
78
+ return 'background';
79
79
  }
80
80
  // there is no sky layer in the Mapbox iOS SDK
81
81
  return null;
@@ -1,4 +1,6 @@
1
+ export declare function toCamelCase(s: any): any;
2
+ export declare function toPascalCase(s: any): any;
3
+ export declare function transformValue(key: any, value: any): any;
1
4
  export declare class PropertyParser {
2
- static parsePropertiesForLayer(propertiesObject: any): any[];
3
5
  static propertyValueFromLayer(layer: any, key: string): any;
4
6
  }
@@ -1,42 +1,43 @@
1
1
  import { Color } from '@nativescript/core';
2
- function toCamelCase(s) {
2
+ export function toCamelCase(s) {
3
3
  return s.replace(/([-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', ''));
4
4
  }
5
- function toPascalCase(s) {
5
+ export function toPascalCase(s) {
6
6
  return s.replace(/(^[a-z]|[-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', ''));
7
7
  }
8
- const Expression = com.mapbox.mapboxsdk.style.expressions.Expression;
9
- function transformValue(key, value) {
8
+ const Expression = com.mapbox.maps.extension.style.expressions.generated.Expression;
9
+ export function transformValue(key, value) {
10
10
  let nValue = value;
11
11
  if (Array.isArray(value)) {
12
- nValue = Expression.Converter.convert(JSON.stringify(value));
12
+ nValue = Expression.fromRaw(JSON.stringify(value));
13
13
  }
14
14
  if (key.indexOf('-color') !== -1 && !Array.isArray(value)) {
15
15
  const color = value instanceof Color ? value : new Color(value);
16
16
  nValue = color.android;
17
17
  }
18
- else if (typeof value === 'number') {
19
- nValue = new java.lang.Float(value);
18
+ else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
19
+ nValue = Expression.literal(value);
20
20
  }
21
- else if (typeof value === 'boolean') {
22
- nValue = new java.lang.Boolean(value);
21
+ else if (Array.isArray(value)) {
22
+ // assume it's a JSON-style expression
23
+ nValue = Expression.fromRaw(JSON.stringify(value));
23
24
  }
24
25
  return nValue;
25
26
  }
26
27
  export class PropertyParser {
27
- static parsePropertiesForLayer(propertiesObject) {
28
- const nProperties = [];
29
- const PropertyFactory = com.mapbox.mapboxsdk.style.layers.PropertyFactory;
30
- if (propertiesObject) {
31
- Object.keys(propertiesObject).forEach((k) => {
32
- const actualKey = toCamelCase(k);
33
- const value = propertiesObject[k];
34
- const nValue = transformValue(k, value);
35
- nProperties.push(PropertyFactory[actualKey](nValue));
36
- });
37
- }
38
- return nProperties;
39
- }
28
+ // static parsePropertiesForLayer(propertiesObject) {
29
+ // const nProperties = [];
30
+ // const PropertyFactory = com.mapbox.maps.extension.style.layers.PropertyFactory;
31
+ // if (propertiesObject) {
32
+ // Object.keys(propertiesObject).forEach((k) => {
33
+ // const actualKey = toCamelCase(k);
34
+ // const value = propertiesObject[k];
35
+ // const nValue = transformValue(k, value);
36
+ // nProperties.push(PropertyFactory[actualKey](nValue));
37
+ // });
38
+ // }
39
+ // return nProperties;
40
+ // }
40
41
  static propertyValueFromLayer(layer, key) {
41
42
  const getterMethodName = `get${toPascalCase(key)}`;
42
43
  let nValue;
@@ -47,11 +48,11 @@ export class PropertyParser {
47
48
  // native method seems not exist
48
49
  return null;
49
50
  }
50
- if (!nValue || nValue.isNull()) {
51
+ if (nValue === null || nValue === undefined) {
51
52
  return null;
52
53
  }
53
54
  if (nValue.isExpression()) {
54
- return JSON.parse(nValue.getExpression().toString());
55
+ return JSON.parse(nValue.toString());
55
56
  }
56
57
  else if (!!nValue.getColorInt()) {
57
58
  return new Color(nValue.getColorInt().intValue());
@@ -0,0 +1,35 @@
1
+ import { StackLayout } from '@nativescript/core';
2
+ /**
3
+ * Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window.
4
+ */
5
+ export declare class AndroidMarker {
6
+ position: com.mapbox.geojson.Point;
7
+ icon: android.graphics.Bitmap;
8
+ title?: string;
9
+ snippet?: string;
10
+ preventNextUpdateOffsetX?: boolean;
11
+ pointAnnotation: com.mapbox.maps.plugin.annotation.generated.PointAnnotation;
12
+ viewAnnotation: android.view.View;
13
+ view: StackLayout;
14
+ anchor: com.mapbox.maps.ViewAnnotationAnchorConfig;
15
+ layerId: string;
16
+ prepared: boolean;
17
+ private static readonly MARKER_PADDING_PX;
18
+ constructor(opts: {
19
+ position: com.mapbox.geojson.Point;
20
+ icon: android.graphics.Bitmap;
21
+ title?: string;
22
+ snippet?: string;
23
+ });
24
+ /**
25
+ * Create the native PointAnnotation
26
+ */
27
+ prepareAnnotationMarker(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager, layerId: string): void;
28
+ update(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager): void;
29
+ /**
30
+ * Build a NativeScript view to use as info window.
31
+ * Then attach it to Mapbox via ViewAnnotationManager.
32
+ */
33
+ prepareViewAnnotation(mapView: com.mapbox.maps.MapView, onInfoWindowClick: any): void;
34
+ destroy(): void;
35
+ }