@nativescript-community/ui-mapbox 6.2.10 → 6.2.14

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +199 -99
  3. package/{mapbox.common.d.ts → common.d.ts} +42 -4
  4. package/{mapbox.common.js → common.js} +21 -1
  5. package/{filter/filter-parser.android.d.ts → expression/expression-parser.android.d.ts} +1 -1
  6. package/{filter/filter-parser.android.js → expression/expression-parser.android.js} +2 -2
  7. package/expression/expression-parser.d.ts +4 -0
  8. package/{filter/filter-parser.ios.d.ts → expression/expression-parser.ios.d.ts} +1 -1
  9. package/{filter/filter-parser.ios.js → expression/expression-parser.ios.js} +2 -2
  10. package/{mapbox.android.d.ts → index.android.d.ts} +9 -14
  11. package/{mapbox.android.js → index.android.js} +152 -65
  12. package/index.d.ts +99 -6
  13. package/{mapbox.ios.d.ts → index.ios.d.ts} +7 -30
  14. package/{mapbox.ios.js → index.ios.js} +1977 -1912
  15. package/layers/layer-factory.android.d.ts +15 -1
  16. package/layers/layer-factory.android.js +63 -2
  17. package/layers/layer-factory.d.ts +17 -2
  18. package/layers/layer-factory.ios.d.ts +15 -1
  19. package/layers/layer-factory.ios.js +72 -2
  20. package/layers/parser/property-parser.android.d.ts +1 -0
  21. package/layers/parser/property-parser.android.js +25 -0
  22. package/layers/parser/property-parser.d.ts +4 -0
  23. package/layers/parser/property-parser.ios.d.ts +1 -0
  24. package/layers/parser/property-parser.ios.js +21 -0
  25. package/package.json +55 -49
  26. package/platforms/android/include.gradle +3 -0
  27. package/platforms/android/ui_mapbox.aar +0 -0
  28. package/platforms/ios/Podfile +2 -2
  29. package/typings/Mapbox.ios.d.ts +2 -0
  30. package/LICENSE +0 -21
@@ -1,4 +1,18 @@
1
- import { LayerCommon } from '../mapbox.common';
1
+ import { LayerCommon, LayerType } from "../common";
2
+ export declare class Layer implements LayerCommon {
3
+ id: string;
4
+ private instance;
5
+ constructor(instance: any);
6
+ visibility(): boolean;
7
+ show(): void;
8
+ hide(): void;
9
+ getNativeInstance(): any;
10
+ setFilter(filter: any[]): void;
11
+ getFilter(): any[];
12
+ setProperty(name: string, value: any): void;
13
+ getProperty(name: string): any;
14
+ type(): LayerType;
15
+ }
2
16
  export declare class LayerFactory {
3
17
  static createLayer(style: any, source: any): Promise<LayerCommon>;
4
18
  private static parseProperties;
@@ -1,5 +1,66 @@
1
- import { Layer } from '../mapbox.android';
2
- import { PropertyParser } from './parser/property-parser.android';
1
+ import { ExpressionParser } from '../expression/expression-parser';
2
+ import { PropertyParser } from './parser/property-parser';
3
+ export class Layer {
4
+ constructor(instance) {
5
+ this.instance = instance;
6
+ this.id = instance.getId();
7
+ }
8
+ visibility() {
9
+ return this.instance.getVisibility().getValue() === 'visible' ? true : false;
10
+ }
11
+ show() {
12
+ this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'visible')]);
13
+ }
14
+ hide() {
15
+ this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'none')]);
16
+ }
17
+ getNativeInstance() {
18
+ return this.instance;
19
+ }
20
+ setFilter(filter) {
21
+ this.instance.setFilter(ExpressionParser.parseJson(filter));
22
+ }
23
+ getFilter() {
24
+ return ExpressionParser.toJson(this.instance.getFilter());
25
+ }
26
+ setProperty(name, value) {
27
+ const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
28
+ this.instance.setProperties(properties);
29
+ }
30
+ getProperty(name) {
31
+ return PropertyParser.propertyValueFromLayer(this.instance, name);
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
+ }
63
+ }
3
64
  export class LayerFactory {
4
65
  static async createLayer(style, source) {
5
66
  const layerProperties = this.parseProperties(style.type, Object.assign(style.paint || {}, style.layout || {}));
@@ -1,5 +1,20 @@
1
- import { LayerCommon } from '..';
1
+ import { LayerCommon, LayerType } from "../common"
2
2
 
3
3
  declare class LayerFactory {
4
4
  static createLayer(style, source): Promise<LayerCommon>;
5
- }
5
+ }
6
+
7
+ export declare class Layer implements LayerCommon {
8
+ id: string;
9
+ private instance;
10
+ constructor(instance: any);
11
+ visibility(): boolean;
12
+ show(): void;
13
+ hide(): void;
14
+ getNativeInstance(): any;
15
+ setFilter(filter: any[]): void;
16
+ getFilter(): any[];
17
+ setProperty(name: string, value: any): void;
18
+ getProperty(name: string): any;
19
+ type(): LayerType;
20
+ }
@@ -1,5 +1,19 @@
1
- import { LayerCommon } from '../mapbox.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;
5
5
  }
6
+ export declare class Layer implements LayerCommon {
7
+ id: string;
8
+ private instance;
9
+ constructor(instance: MGLStyleLayer);
10
+ type(): LayerType;
11
+ visibility(): boolean;
12
+ show(): void;
13
+ hide(): void;
14
+ getNativeInstance(): any;
15
+ setFilter(filter: any[]): void;
16
+ getFilter(): any[];
17
+ setProperty(name: string, value: any): void;
18
+ getProperty(name: string): any;
19
+ }
@@ -1,5 +1,5 @@
1
- import { Layer } from '../mapbox.ios';
2
- import { PropertyParser } from './parser/property-parser.ios';
1
+ import { ExpressionParser } from '../expression/expression-parser';
2
+ import { PropertyParser } from './parser/property-parser';
3
3
  export class LayerFactory {
4
4
  static async createLayer(style, source) {
5
5
  let nativeLayer;
@@ -44,4 +44,74 @@ export class LayerFactory {
44
44
  return PropertyParser.parsePropertiesForLayer(propertiesObject);
45
45
  }
46
46
  }
47
+ export class Layer {
48
+ constructor(instance) {
49
+ this.instance = instance;
50
+ this.id = instance.identifier;
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
+ }
82
+ visibility() {
83
+ return this.instance.visible;
84
+ }
85
+ show() {
86
+ this.instance.visible = true;
87
+ }
88
+ hide() {
89
+ this.instance.visible = false;
90
+ }
91
+ getNativeInstance() {
92
+ return this.instance;
93
+ }
94
+ setFilter(filter) {
95
+ if (this.instance instanceof MGLVectorStyleLayer) {
96
+ this.instance.predicate = ExpressionParser.parseJson(filter);
97
+ }
98
+ else {
99
+ throw new Error('Set filter only support for vector layer.');
100
+ }
101
+ }
102
+ getFilter() {
103
+ return ExpressionParser.toJson(this.instance.predicate);
104
+ }
105
+ setProperty(name, value) {
106
+ const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
107
+ for (const propKey in properties) {
108
+ if (Object.prototype.hasOwnProperty.call(properties, propKey)) {
109
+ this.instance[propKey] = properties[propKey];
110
+ }
111
+ }
112
+ }
113
+ getProperty(name) {
114
+ return PropertyParser.propertyValueFromLayer(this.instance, name);
115
+ }
116
+ }
47
117
  //# sourceMappingURL=layer-factory.ios.js.map
@@ -1,3 +1,4 @@
1
1
  export declare class PropertyParser {
2
2
  static parsePropertiesForLayer(propertiesObject: any): any[];
3
+ static propertyValueFromLayer(layer: any, key: string): any;
3
4
  }
@@ -2,6 +2,9 @@ import { Color } from '@nativescript/core';
2
2
  function toCamelCase(s) {
3
3
  return s.replace(/([-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', ''));
4
4
  }
5
+ function toPascalCase(s) {
6
+ return s.replace(/(^[a-z]|[-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', ''));
7
+ }
5
8
  const Expression = com.mapbox.mapboxsdk.style.expressions.Expression;
6
9
  function transformValue(key, value) {
7
10
  let nValue = value;
@@ -34,5 +37,27 @@ export class PropertyParser {
34
37
  }
35
38
  return nProperties;
36
39
  }
40
+ static propertyValueFromLayer(layer, key) {
41
+ const getterMethodName = `get${toPascalCase(key)}`;
42
+ let nValue;
43
+ try {
44
+ nValue = layer[getterMethodName]();
45
+ }
46
+ catch (e) {
47
+ return null;
48
+ }
49
+ if (!nValue || nValue.isNull()) {
50
+ return null;
51
+ }
52
+ if (nValue.isExpression()) {
53
+ return JSON.parse(nValue.getExpression().toString());
54
+ }
55
+ else if (!!nValue.getColorInt()) {
56
+ return new Color(nValue.getColorInt().intValue());
57
+ }
58
+ else {
59
+ return nValue.getValue();
60
+ }
61
+ }
37
62
  }
38
63
  //# sourceMappingURL=property-parser.android.js.map
@@ -0,0 +1,4 @@
1
+ export declare class PropertyParser {
2
+ static parsePropertiesForLayer(propertiesObject: any): any;
3
+ static propertyValueFromLayer(layer, key: string): any;
4
+ }
@@ -1,3 +1,4 @@
1
1
  export declare class PropertyParser {
2
2
  static parsePropertiesForLayer(propertiesObject: any): {};
3
+ static propertyValueFromLayer(layer: any, key: string): any;
3
4
  }
@@ -77,5 +77,26 @@ export class PropertyParser {
77
77
  }
78
78
  return nProperties;
79
79
  }
80
+ static propertyValueFromLayer(layer, key) {
81
+ const actualKey = keysMap[key] || toCamelCase(key);
82
+ const nValue = layer[actualKey];
83
+ if (!nValue) {
84
+ return null;
85
+ }
86
+ if (nValue.expressionType === 0) {
87
+ if (nValue.constantValue instanceof UIColor) {
88
+ return Color.fromIosColor(nValue.constantValue);
89
+ }
90
+ else {
91
+ return nValue.constantValue;
92
+ }
93
+ }
94
+ else {
95
+ const expressionObj = nValue.mgl_jsonExpressionObject;
96
+ const data = NSJSONSerialization.dataWithJSONObjectOptionsError(expressionObj, 0);
97
+ const expression = NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding);
98
+ return JSON.parse(expression);
99
+ }
100
+ }
80
101
  }
81
102
  //# sourceMappingURL=property-parser.ios.js.map
package/package.json CHANGED
@@ -1,52 +1,58 @@
1
1
  {
2
- "name": "@nativescript-community/ui-mapbox",
3
- "version": "6.2.10",
4
- "description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
5
- "main": "mapbox",
6
- "typings": "index.d.ts",
7
- "nativescript": {
8
- "platforms": {
9
- "android": "3.0.0",
10
- "ios": "3.0.0"
11
- }
12
- },
13
- "keywords": [
14
- "NativeScript",
15
- "Map",
16
- "Maps",
17
- "Native Maps",
18
- "Mapbox",
19
- "iOS",
20
- "Android",
21
- "Angular",
22
- "preview|https://raw.githubusercontent.com/nativescript-community/ui-mapbox/master/images/preview.png"
23
- ],
24
- "author": {
25
- "name": "Yermo Lamers",
26
- "email": "yml@yml.com",
27
- "url": "https://miles-by-motorcycle.com/flyingbricksoftware/about"
28
- },
29
- "contributors": [
30
- {
31
- "name": "Eddy Verbruggen - Original Author",
32
- "email": "eddyverbruggen@gmail.com"
2
+ "name": "@nativescript-community/ui-mapbox",
3
+ "version": "6.2.14",
4
+ "description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
5
+ "main": "index",
6
+ "typings": "index.d.ts",
7
+ "scripts": {
8
+ "build": "npm run tsc && npm run readme",
9
+ "readme": "../../node_modules/.bin/readme generate -c ../../tools/readme/blueprint.json",
10
+ "tsc": "../../node_modules/.bin/cpy '**/*.d.ts' '../../packages/ui-mapbox' --parents --cwd=../../src/ui-mapbox && ../../node_modules/.bin/tsc -skipLibCheck -d",
11
+ "clean": "../../node_modules/.bin/rimraf ./*.d.ts ./*.js ./*.js.map"
33
12
  },
34
- {
35
- "name": "Alex Wells",
36
- "email": "autaut03@gmail.com"
37
- }
38
- ],
39
- "license": "MIT",
40
- "bugs": {
41
- "url": "https://github.com/nativescript-community/ui-mapbox/issues"
42
- },
43
- "repository": {
44
- "type": "git",
45
- "url": "https://github.com/nativescript-community/ui-mapbox"
46
- },
47
- "readmeFilename": "README.md",
48
- "dependencies": {
49
- "@nativescript-community/perms": "^2.1.1"
50
- },
51
- "gitHead": "4d9cf3782e07e94b05b161306b89b5c9bcfd4149"
13
+ "nativescript": {
14
+ "platforms": {
15
+ "android": "3.0.0",
16
+ "ios": "3.0.0"
17
+ }
18
+ },
19
+ "keywords": [
20
+ "NativeScript",
21
+ "Map",
22
+ "Maps",
23
+ "Native Maps",
24
+ "Mapbox",
25
+ "iOS",
26
+ "Android",
27
+ "Angular",
28
+ "preview|https://raw.githubusercontent.com/nativescript-community/ui-mapbox/master/images/preview.png"
29
+ ],
30
+ "author": {
31
+ "name": "Yermo Lamers",
32
+ "email": "yml@yml.com",
33
+ "url": "https://miles-by-motorcycle.com/flyingbricksoftware/about"
34
+ },
35
+ "contributors": [
36
+ {
37
+ "name": "Eddy Verbruggen - Original Author",
38
+ "email": "eddyverbruggen@gmail.com"
39
+ },
40
+ {
41
+ "name": "Alex Wells",
42
+ "email": "autaut03@gmail.com"
43
+ }
44
+ ],
45
+ "license": "MIT",
46
+ "bugs": {
47
+ "url": "https://github.com/nativescript-community/ui-mapbox/issues"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/nativescript-community/ui-mapbox"
52
+ },
53
+ "readmeFilename": "README.md",
54
+ "dependencies": {
55
+ "@nativescript-community/perms": "^2.2.0"
56
+ },
57
+ "gitHead": "f3399295d88474fe637cacc301445c977a91540d"
52
58
  }
@@ -10,6 +10,7 @@ dependencies {
10
10
  def mapboxPluginsVersion = project.hasProperty("mapboxPluginsVersion") ? project.mapboxPluginsVersion : "v9"
11
11
  def mapboxAnnotationPluginVersion = project.hasProperty("mapboxAnnotationPluginVersion") ? project.mapboxAnnotationPluginVersion : "0.9.0"
12
12
  def mapboxGesturesVersion = project.hasProperty("mapboxGesturesVersion") ? project.mapboxGesturesVersion : "0.7.0"
13
+ def squareupVersion = project.hasProperty("squareupVersion") ? project.mapboxGesturesVersion : "4.9.0"
13
14
 
14
15
  implementation "com.mapbox.mapboxsdk:mapbox-android-telemetry:$mapboxTelemetryVersion"
15
16
 
@@ -28,6 +29,8 @@ dependencies {
28
29
  // Annotation Plugin
29
30
 
30
31
  implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-$mapboxPluginsVersion:$mapboxAnnotationPluginVersion"
32
+
33
+ implementation "com.squareup.okhttp3:okhttp:$squareupVersion"
31
34
  }
32
35
 
33
36
  android {
Binary file
@@ -1,3 +1,3 @@
1
- platform :ios, '10.0'
1
+ platform :ios, '13.0'
2
2
 
3
- pod 'Mapbox-iOS-SDK'
3
+ pod 'Mapbox-iOS-SDK', '~> 5.1.1'
@@ -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;
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright 2018 Eddy Verbruggen
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.