@nativescript-community/ui-mapbox 6.2.12 → 6.2.13
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 +8 -0
- package/common.d.ts +4 -1
- package/common.js +1 -1
- package/{filter/filter-parser.android.d.ts → expression/expression-parser.android.d.ts} +1 -1
- package/{filter/filter-parser.android.js → expression/expression-parser.android.js} +2 -2
- package/{filter/filter-parser.d.ts → expression/expression-parser.d.ts} +1 -1
- package/{filter/filter-parser.ios.d.ts → expression/expression-parser.ios.d.ts} +1 -1
- package/{filter/filter-parser.ios.js → expression/expression-parser.ios.js} +2 -2
- package/index.android.js +14 -4
- package/index.ios.js +16 -4
- package/layers/layer-factory.android.js +3 -3
- package/layers/layer-factory.ios.js +3 -3
- package/package.json +2 -2
- package/typings/Mapbox.ios.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.13](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.12...v6.2.13) (2022-01-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-mapbox
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [6.2.12](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.11...v6.2.12) (2022-01-17)
|
|
7
15
|
|
|
8
16
|
**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 './
|
|
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";
|
|
@@ -170,6 +170,9 @@ export interface GeoJSONSource extends Source {
|
|
|
170
170
|
cluster?: {
|
|
171
171
|
radius: any;
|
|
172
172
|
maxZoom: any;
|
|
173
|
+
properties?: {
|
|
174
|
+
[property: string]: [any, any];
|
|
175
|
+
};
|
|
173
176
|
};
|
|
174
177
|
}
|
|
175
178
|
export declare type UserLocationCameraMode = 'NONE' | 'NONE_COMPASS' | 'NONE_GPS' | 'TRACKING' | 'TRACKING_COMPASS' | 'TRACKING_GPS' | 'TRACKING_GPS_NORTH';
|
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 './
|
|
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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
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=
|
|
16
|
+
//# sourceMappingURL=expression-parser.android.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
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=
|
|
22
|
+
//# sourceMappingURL=expression-parser.ios.js.map
|
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 {
|
|
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 ?
|
|
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 ?
|
|
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
|
}
|
|
@@ -1855,6 +1855,16 @@ export class Mapbox extends MapboxCommon {
|
|
|
1855
1855
|
.withCluster(true)
|
|
1856
1856
|
.withClusterMaxZoom(options.cluster.maxZoom || 13)
|
|
1857
1857
|
.withClusterRadius(options.cluster.radius || 40);
|
|
1858
|
+
if (options.cluster.properties) {
|
|
1859
|
+
for (const property of Object.keys(options.cluster.properties)) {
|
|
1860
|
+
const propertyValues = options.cluster.properties[property];
|
|
1861
|
+
let operator = propertyValues[0];
|
|
1862
|
+
if (!Array.isArray(operator)) {
|
|
1863
|
+
operator = [operator];
|
|
1864
|
+
}
|
|
1865
|
+
geojsonOptions.withClusterProperty(property, ExpressionParser.parseJson(operator), ExpressionParser.parseJson(propertyValues[1]));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1858
1868
|
}
|
|
1859
1869
|
const geoJsonSource = new com.mapbox.mapboxsdk.style.sources.GeoJsonSource(id, geojsonOptions);
|
|
1860
1870
|
if (options.data) {
|
|
@@ -1961,7 +1971,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1961
1971
|
if (!lineSource) {
|
|
1962
1972
|
throw new Error(`no source found with id: ${sId}`);
|
|
1963
1973
|
}
|
|
1964
|
-
const lineFeatures = lineSource.querySourceFeatures(
|
|
1974
|
+
const lineFeatures = lineSource.querySourceFeatures(ExpressionParser.parseJson(['==', '$type', 'LineString']));
|
|
1965
1975
|
if (lineFeatures.size() === 0) {
|
|
1966
1976
|
throw new Error('no line string feature found');
|
|
1967
1977
|
}
|
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 {
|
|
4
|
+
import { ExpressionParser } from './expression/expression-parser';
|
|
5
5
|
var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
|
|
6
6
|
__extends(MGLMapViewDelegateImpl, _super);
|
|
7
7
|
function MGLMapViewDelegateImpl() {
|
|
@@ -1436,7 +1436,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
const { x, y } = theMap.convertCoordinateToPointToView({ latitude: options.point.lat, longitude: options.point.lng }, theMap);
|
|
1438
1438
|
const queryLayerIds = options.layers ? NSSet.setWithArray(Utils.ios.collections.jsArrayToNSArray(options.layers)) : null;
|
|
1439
|
-
const queryFilter = options.filter ?
|
|
1439
|
+
const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
|
|
1440
1440
|
const features = theMap.visibleFeaturesAtPointInStyleLayersWithIdentifiersPredicate({ x, y }, queryLayerIds, queryFilter);
|
|
1441
1441
|
const result = [];
|
|
1442
1442
|
for (let i = 0; i < features.count; i++) {
|
|
@@ -1466,7 +1466,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1466
1466
|
throw new Error(`Source with id "${sourceId}" not found.`);
|
|
1467
1467
|
}
|
|
1468
1468
|
let features;
|
|
1469
|
-
const queryFilter = options.filter ?
|
|
1469
|
+
const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
|
|
1470
1470
|
if (source instanceof MGLShapeSource) {
|
|
1471
1471
|
features = source.featuresMatchingPredicate(queryFilter);
|
|
1472
1472
|
}
|
|
@@ -2143,6 +2143,18 @@ export class Mapbox extends MapboxCommon {
|
|
|
2143
2143
|
sourceOptions[MGLShapeSourceOptionClustered] = true;
|
|
2144
2144
|
sourceOptions[MGLShapeSourceOptionClusterRadius] = options.cluster.radius || 40;
|
|
2145
2145
|
sourceOptions[MGLShapeSourceOptionMaximumZoomLevelForClustering] = options.cluster.maxZoom || 13;
|
|
2146
|
+
if (options.cluster.properties) {
|
|
2147
|
+
const clusterProperties = {};
|
|
2148
|
+
for (const property of Object.keys(options.cluster.properties)) {
|
|
2149
|
+
let [operator, operand] = options.cluster.properties[property];
|
|
2150
|
+
if (!Array.isArray(operator)) {
|
|
2151
|
+
operator = [operator];
|
|
2152
|
+
}
|
|
2153
|
+
const expressions = Utils.ios.collections.jsArrayToNSArray([ExpressionParser.parseJson(operator), ExpressionParser.parseJson(operand)]);
|
|
2154
|
+
clusterProperties[property] = expressions;
|
|
2155
|
+
}
|
|
2156
|
+
sourceOptions[MGLShapeSourceOptionClusterProperties] = clusterProperties;
|
|
2157
|
+
}
|
|
2146
2158
|
}
|
|
2147
2159
|
source = MGLShapeSource.alloc().initWithIdentifierShapeOptions(id, geoJsonShape, sourceOptions);
|
|
2148
2160
|
break;
|
|
@@ -2269,7 +2281,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2269
2281
|
throw new Error(`no source found with id: ${sId}`);
|
|
2270
2282
|
}
|
|
2271
2283
|
try {
|
|
2272
|
-
const lineFeatures = lineSource.featuresMatchingPredicate(
|
|
2284
|
+
const lineFeatures = lineSource.featuresMatchingPredicate(ExpressionParser.parseJson(['==', '$type', 'LineString']));
|
|
2273
2285
|
if (lineFeatures.count === 0) {
|
|
2274
2286
|
throw new Error('no line string feature found');
|
|
2275
2287
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
21
|
+
this.instance.setFilter(ExpressionParser.parseJson(filter));
|
|
22
22
|
}
|
|
23
23
|
getFilter() {
|
|
24
|
-
return
|
|
24
|
+
return ExpressionParser.toJson(this.instance.getFilter());
|
|
25
25
|
}
|
|
26
26
|
setProperty(name, value) {
|
|
27
27
|
const properties = PropertyParser.parsePropertiesForLayer({ [name]: value });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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) {
|
|
@@ -63,14 +63,14 @@ export class Layer {
|
|
|
63
63
|
}
|
|
64
64
|
setFilter(filter) {
|
|
65
65
|
if (this.instance instanceof MGLVectorStyleLayer) {
|
|
66
|
-
this.instance.predicate =
|
|
66
|
+
this.instance.predicate = ExpressionParser.parseJson(filter);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
throw new Error('Set filter only support for vector layer.');
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
getFilter() {
|
|
73
|
-
return
|
|
73
|
+
return ExpressionParser.toJson(this.instance.predicate);
|
|
74
74
|
}
|
|
75
75
|
setProperty(name, value) {
|
|
76
76
|
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.
|
|
3
|
+
"version": "6.2.13",
|
|
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": "
|
|
57
|
+
"gitHead": "e6c89b9d4b3505ecdb5864fd58c01721a3b572ff"
|
|
58
58
|
}
|
package/typings/Mapbox.ios.d.ts
CHANGED
|
@@ -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;
|