proximiio-js-library 1.9.3 → 1.9.6
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/README.md +5 -0
- package/lib/components/map/custom-layers.js +12 -1
- package/lib/components/map/main.d.ts +6 -0
- package/lib/components/map/main.js +43 -13
- package/lib/controllers/geo.js +11 -9
- package/lib/models/style.d.ts +1 -0
- package/lib/models/style.js +3 -0
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,6 +140,11 @@ const map = new Proximiio.Map({
|
|
|
140
140
|
defaultLabelColor: string; // optional, default: '#6945ed', default color of the polygon labels
|
|
141
141
|
hoverLabelColor: string; // optional, default: '#fff', hover color of the polygon labels
|
|
142
142
|
selectedLabelColor: string; // optional, default: '#fff', selected color of the polygon labels
|
|
143
|
+
defaultPolygonHeight: number; // optional, default: 3, default polygon height in meters
|
|
144
|
+
hoverPolygonHeight: number; // optional, default: 3, hover polygon height in meters
|
|
145
|
+
selectedPolygonHeight: number; // optional, default: 3, selected polygon height in meters
|
|
146
|
+
base: number; // optional, default: 0, default polygon base in meters
|
|
147
|
+
opacity: number; // optional, default: 1, default polygon opacity
|
|
143
148
|
}
|
|
144
149
|
considerVisibilityParam: false, // optional, default: true, if enabled all pois with visibility property defined as 'hidden' will not be visible as default, will be possible to toggle them with toggleHiddenPois() method
|
|
145
150
|
fitBoundsPadding: 200, // optional, default 250, number | PaddingOptions, the amount of padding in pixels to add to the given bounds for found route, https://docs.mapbox.com/mapbox-gl-js/api/properties/#paddingoptions
|
|
@@ -29,7 +29,18 @@ var PolygonsLayer = /** @class */ (function (_super) {
|
|
|
29
29
|
_this.source = 'main';
|
|
30
30
|
_this.filter = ['all', ['==', ['get', 'type'], 'shop-custom'], ['==', ['to-number', ['get', 'level']], 0]];
|
|
31
31
|
_this.paint = new fill_extrusion_layer_1.PaintProperties({
|
|
32
|
-
'fill-extrusion-height':
|
|
32
|
+
'fill-extrusion-height': [
|
|
33
|
+
'case',
|
|
34
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
35
|
+
data.selectedPolygonHeight,
|
|
36
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
37
|
+
data.hoverPolygonHeight,
|
|
38
|
+
['boolean', ['feature-state', 'active'], false],
|
|
39
|
+
data.hoverPolygonHeight,
|
|
40
|
+
data.defaultPolygonHeight,
|
|
41
|
+
],
|
|
42
|
+
'fill-extrusion-base': data.base,
|
|
43
|
+
'fill-extrusion-opacity': data.opacity,
|
|
33
44
|
'fill-extrusion-color': [
|
|
34
45
|
'case',
|
|
35
46
|
['boolean', ['feature-state', 'selected'], false],
|
|
@@ -48,6 +48,11 @@ interface Options {
|
|
|
48
48
|
defaultLabelColor?: string;
|
|
49
49
|
hoverLabelColor?: string;
|
|
50
50
|
selectedLabelColor?: string;
|
|
51
|
+
defaultPolygonHeight?: number;
|
|
52
|
+
hoverPolygonHeight?: number;
|
|
53
|
+
selectedPolygonHeight?: number;
|
|
54
|
+
base?: number;
|
|
55
|
+
opacity?: number;
|
|
51
56
|
};
|
|
52
57
|
zoomLevel?: number;
|
|
53
58
|
considerVisibilityParam?: boolean;
|
|
@@ -109,6 +114,7 @@ export declare class Map {
|
|
|
109
114
|
private filteredFeatures;
|
|
110
115
|
private hiddenFeatures;
|
|
111
116
|
private filteredAmenities;
|
|
117
|
+
private amenityFilters;
|
|
112
118
|
private hiddenAmenities;
|
|
113
119
|
private amenityCategories;
|
|
114
120
|
private hoveredPolygon;
|
|
@@ -134,6 +134,11 @@ var Map = /** @class */ (function () {
|
|
|
134
134
|
defaultLabelColor: '#6945ed',
|
|
135
135
|
hoverLabelColor: '#fff',
|
|
136
136
|
selectedLabelColor: '#fff',
|
|
137
|
+
defaultPolygonHeight: 3,
|
|
138
|
+
hoverPolygonHeight: 3,
|
|
139
|
+
selectedPolygonHeight: 3,
|
|
140
|
+
base: 0,
|
|
141
|
+
opacity: 1,
|
|
137
142
|
},
|
|
138
143
|
considerVisibilityParam: true,
|
|
139
144
|
fitBoundsPadding: 250,
|
|
@@ -155,6 +160,7 @@ var Map = /** @class */ (function () {
|
|
|
155
160
|
this.filteredFeatures = [];
|
|
156
161
|
this.hiddenFeatures = [];
|
|
157
162
|
this.filteredAmenities = [];
|
|
163
|
+
this.amenityFilters = [];
|
|
158
164
|
this.hiddenAmenities = [];
|
|
159
165
|
this.amenityCategories = {};
|
|
160
166
|
// Used to increment the value of the point measurement against the route.
|
|
@@ -217,7 +223,7 @@ var Map = /** @class */ (function () {
|
|
|
217
223
|
Map.prototype.fetch = function () {
|
|
218
224
|
var _a, _b, _c;
|
|
219
225
|
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var placeParam, urlParams, _d, places, style, styles, features, amenities, user, defaultPlace, place, center;
|
|
226
|
+
var placeParam, urlParams, _d, places, style, styles, features, amenities, levelChangers, user, defaultPlace, place, center;
|
|
221
227
|
var _this = this;
|
|
222
228
|
return __generator(this, function (_e) {
|
|
223
229
|
switch (_e.label) {
|
|
@@ -230,6 +236,7 @@ var Map = /** @class */ (function () {
|
|
|
230
236
|
return [4 /*yield*/, repository_1.default.getPackage(this.defaultOptions.initPolygons)];
|
|
231
237
|
case 1:
|
|
232
238
|
_d = _e.sent(), places = _d.places, style = _d.style, styles = _d.styles, features = _d.features, amenities = _d.amenities;
|
|
239
|
+
levelChangers = features.features.filter(function (f) { return f.properties.type === 'elevator' || f.properties.type === 'escalator' || f.properties.type === 'staircase'; });
|
|
233
240
|
return [4 /*yield*/, auth_1.default.getCurrentUser()];
|
|
234
241
|
case 2:
|
|
235
242
|
user = _e.sent();
|
|
@@ -260,7 +267,7 @@ var Map = /** @class */ (function () {
|
|
|
260
267
|
this.imageSourceManager.enabled = this.defaultOptions.showRasterFloorplans;
|
|
261
268
|
this.imageSourceManager.belowLayer = style.usesPrefixes() ? 'proximiio-floors' : 'floors';
|
|
262
269
|
this.imageSourceManager.initialize();
|
|
263
|
-
this.state = __assign(__assign({}, this.state), { initializing: false, place: place, places: places, style: style, styles: styles, amenities: amenities, features: features, allFeatures: new feature_1.FeatureCollection(features), latitude: center[1], longitude: center[0], zoom: this.defaultOptions.zoomLevel ? this.defaultOptions.zoomLevel : (_c = this.defaultOptions.mapboxOptions) === null || _c === void 0 ? void 0 : _c.zoom, noPlaces: places.length === 0, user: user });
|
|
270
|
+
this.state = __assign(__assign({}, this.state), { initializing: false, place: place, places: places, style: style, styles: styles, amenities: amenities, features: features, allFeatures: new feature_1.FeatureCollection(features), levelChangers: new feature_1.FeatureCollection({ features: levelChangers }), latitude: center[1], longitude: center[0], zoom: this.defaultOptions.zoomLevel ? this.defaultOptions.zoomLevel : (_c = this.defaultOptions.mapboxOptions) === null || _c === void 0 ? void 0 : _c.zoom, noPlaces: places.length === 0, user: user });
|
|
264
271
|
style.on(this.onStyleChange);
|
|
265
272
|
this.map = new mapboxgl.Map(__assign(__assign({}, this.defaultOptions.mapboxOptions), { container: this.defaultOptions.selector ? this.defaultOptions.selector : 'map' }));
|
|
266
273
|
this.map.setStyle(this.state.style);
|
|
@@ -449,6 +456,7 @@ var Map = /** @class */ (function () {
|
|
|
449
456
|
}
|
|
450
457
|
};
|
|
451
458
|
Map.prototype.initDirectionIcon = function () {
|
|
459
|
+
var _this = this;
|
|
452
460
|
if (this.map) {
|
|
453
461
|
this.state.style.addSource('direction-icon-source', {
|
|
454
462
|
type: 'geojson',
|
|
@@ -476,6 +484,17 @@ var Map = /** @class */ (function () {
|
|
|
476
484
|
},
|
|
477
485
|
filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
|
|
478
486
|
});
|
|
487
|
+
this.map.on('click', 'proximiio-levelchangers', function (ev) {
|
|
488
|
+
if (_this.routingSource.points) {
|
|
489
|
+
var directionIcon = _this.state.style
|
|
490
|
+
.getSource('direction-icon-source')
|
|
491
|
+
.data.features.find(function (f) { return f.properties.level === _this.state.floor.level; });
|
|
492
|
+
var way = directionIcon ? (directionIcon.properties.icon === 'floorchange-up-image' ? 'up' : 'down') : null;
|
|
493
|
+
if (way && ev.features[0].properties.id === directionIcon.properties.levelChangerId) {
|
|
494
|
+
_this.setFloorByWay(way);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
});
|
|
479
498
|
}
|
|
480
499
|
};
|
|
481
500
|
Map.prototype.initAnimatedRoute = function () {
|
|
@@ -556,6 +575,9 @@ var Map = /** @class */ (function () {
|
|
|
556
575
|
// @ts-ignore
|
|
557
576
|
var polygonPoi = this.state.allFeatures.features.find(function (i) { return i.properties.id === e.features[0].properties.poi_id; });
|
|
558
577
|
var poi = this.state.allFeatures.features.find(function (i) { return i.properties.id === e.features[0].properties.id; });
|
|
578
|
+
if (polygonPoi) {
|
|
579
|
+
this.handlePolygonSelection(polygonPoi);
|
|
580
|
+
}
|
|
559
581
|
this.onPolygonClickListener.next(polygonPoi ? polygonPoi : poi);
|
|
560
582
|
}
|
|
561
583
|
else {
|
|
@@ -584,7 +606,7 @@ var Map = /** @class */ (function () {
|
|
|
584
606
|
}
|
|
585
607
|
}
|
|
586
608
|
if (connectedPolygonId) {
|
|
587
|
-
this.selectedPolygon = this.state.allFeatures.features.find(function (i) { return i.properties.id === connectedPolygonId; });
|
|
609
|
+
this.selectedPolygon = this.state.allFeatures.features.find(function (i) { return i.properties.id === connectedPolygonId && i.properties.type === 'shop-custom'; });
|
|
588
610
|
if (this.selectedPolygon) {
|
|
589
611
|
this.map.setFeatureState({
|
|
590
612
|
source: 'main',
|
|
@@ -940,17 +962,18 @@ var Map = /** @class */ (function () {
|
|
|
940
962
|
for (var key in this.amenityCategories) {
|
|
941
963
|
_loop_3(key);
|
|
942
964
|
}
|
|
943
|
-
this.
|
|
965
|
+
this.amenityFilters = this.amenityIds.filter(function (el) { return !amenities_1.includes(el); });
|
|
944
966
|
}
|
|
945
967
|
else {
|
|
946
968
|
if (inverted && this.hiddenAmenities.findIndex(function (i) { return i === amenityId; }) === -1) {
|
|
947
969
|
this.hiddenAmenities.push(amenityId);
|
|
948
970
|
this.filteredAmenities = this.filteredAmenities.filter(function (i) { return i !== amenityId; });
|
|
949
971
|
}
|
|
950
|
-
else if (!inverted && this.
|
|
951
|
-
this.
|
|
972
|
+
else if (!inverted && this.amenityFilters.findIndex(function (i) { return i === amenityId; }) === -1) {
|
|
973
|
+
this.amenityFilters.push(amenityId);
|
|
952
974
|
}
|
|
953
975
|
}
|
|
976
|
+
this.filteredAmenities = this.amenityFilters;
|
|
954
977
|
this.filterOutFeatures();
|
|
955
978
|
if (!inverted)
|
|
956
979
|
this.setActivePolygons(amenityId);
|
|
@@ -963,7 +986,7 @@ var Map = /** @class */ (function () {
|
|
|
963
986
|
this.amenityCategories[category].active &&
|
|
964
987
|
this.amenityCategories[category].activeId === amenityId) {
|
|
965
988
|
var amenities = this.amenityCategories[category].amenities.filter(function (i) { return i !== amenityId; });
|
|
966
|
-
this.
|
|
989
|
+
this.amenityFilters = this.amenityFilters.concat(amenities);
|
|
967
990
|
this.amenityCategories[category].active = false;
|
|
968
991
|
}
|
|
969
992
|
else if (!category) {
|
|
@@ -973,22 +996,23 @@ var Map = /** @class */ (function () {
|
|
|
973
996
|
this.filteredAmenities.push(amenityId);
|
|
974
997
|
}
|
|
975
998
|
else {
|
|
976
|
-
this.
|
|
999
|
+
this.amenityFilters = this.amenityFilters.filter(function (i) { return i !== amenityId; });
|
|
977
1000
|
}
|
|
978
1001
|
}
|
|
979
|
-
this.filteredAmenities = this.
|
|
1002
|
+
this.filteredAmenities = this.amenityFilters.length > 0 ? this.amenityFilters : this.amenityIds;
|
|
980
1003
|
this.hiddenAmenities = this.hiddenAmenities.length > 0 ? this.hiddenAmenities : [];
|
|
981
1004
|
this.filterOutFeatures();
|
|
982
1005
|
this.setActivePolygons(null);
|
|
983
1006
|
};
|
|
984
1007
|
Map.prototype.onResetAmenityFilters = function () {
|
|
985
|
-
this.
|
|
1008
|
+
this.amenityFilters = [];
|
|
986
1009
|
this.hiddenAmenities = [];
|
|
987
1010
|
for (var key in this.amenityCategories) {
|
|
988
1011
|
if (this.amenityCategories.hasOwnProperty(key)) {
|
|
989
1012
|
this.amenityCategories[key].active = false;
|
|
990
1013
|
}
|
|
991
1014
|
}
|
|
1015
|
+
this.filteredAmenities = this.amenityIds;
|
|
992
1016
|
this.filterOutFeatures();
|
|
993
1017
|
this.setActivePolygons(null);
|
|
994
1018
|
};
|
|
@@ -1073,7 +1097,7 @@ var Map = /** @class */ (function () {
|
|
|
1073
1097
|
: [];
|
|
1074
1098
|
if (activeFeatures.length > 0) {
|
|
1075
1099
|
var _loop_4 = function (f) {
|
|
1076
|
-
var polygon = this_4.state.allFeatures.features.find(function (i) { return i.properties.id === f.properties.metadata.polygon_id; });
|
|
1100
|
+
var polygon = this_4.state.allFeatures.features.find(function (i) { return i.properties.id === f.properties.metadata.polygon_id && i.properties.type === 'shop-custom'; });
|
|
1077
1101
|
if (polygon) {
|
|
1078
1102
|
this_4.map.setFeatureState({
|
|
1079
1103
|
source: 'main',
|
|
@@ -1091,7 +1115,7 @@ var Map = /** @class */ (function () {
|
|
|
1091
1115
|
}
|
|
1092
1116
|
if (amenityFeatures.length > 0) {
|
|
1093
1117
|
var _loop_5 = function (f) {
|
|
1094
|
-
var polygon = this_5.state.allFeatures.features.find(function (i) { return i.properties.id === f.properties.metadata.polygon_id; });
|
|
1118
|
+
var polygon = this_5.state.allFeatures.features.find(function (i) { return i.properties.id === f.properties.metadata.polygon_id && i.properties.type === 'shop-custom'; });
|
|
1095
1119
|
if (polygon) {
|
|
1096
1120
|
this_5.map.setFeatureState({
|
|
1097
1121
|
source: 'main',
|
|
@@ -1610,10 +1634,15 @@ var Map = /** @class */ (function () {
|
|
|
1610
1634
|
.filter(function (i) { return i.isLevelChanger; })
|
|
1611
1635
|
.map(function (i, index, array) {
|
|
1612
1636
|
var feature = _this.state.allFeatures.features.find(function (f) { return f.id === i.id; });
|
|
1637
|
+
var targetPoint = turf.point(feature.geometry.coordinates);
|
|
1638
|
+
var placeLevelChangers = new feature_1.FeatureCollection({
|
|
1639
|
+
features: _this.state.levelChangers.features.filter(function (f) { return f.properties.place_id === _this.state.place.id; }),
|
|
1640
|
+
});
|
|
1641
|
+
var nearestLevelChanger = turf.nearestPoint(targetPoint, placeLevelChangers);
|
|
1613
1642
|
var nextLevelChanger = array[index + 1] ? array[index + 1] : array[index - 1];
|
|
1614
1643
|
return new feature_1.default({
|
|
1615
1644
|
type: 'Feature',
|
|
1616
|
-
geometry:
|
|
1645
|
+
geometry: nearestLevelChanger.geometry,
|
|
1617
1646
|
properties: {
|
|
1618
1647
|
usecase: 'floor-change-symbol',
|
|
1619
1648
|
icon: nextLevelChanger.properties.level > i.properties.level
|
|
@@ -1621,6 +1650,7 @@ var Map = /** @class */ (function () {
|
|
|
1621
1650
|
: 'floorchange-down-image',
|
|
1622
1651
|
iconOffset: nextLevelChanger.properties.level > i.properties.level ? [4, -90] : [4, 90],
|
|
1623
1652
|
level: i.properties.level,
|
|
1653
|
+
levelChangerId: nearestLevelChanger.properties.id,
|
|
1624
1654
|
},
|
|
1625
1655
|
});
|
|
1626
1656
|
});
|
package/lib/controllers/geo.js
CHANGED
|
@@ -62,22 +62,24 @@ var getFeatures = function (initPolygons) { return __awaiter(void 0, void 0, voi
|
|
|
62
62
|
feature.properties.type = 'poi-custom';
|
|
63
63
|
var polygon = res.data.features.find(function (f) { return f.properties.id === feature.properties.metadata.polygon_id; });
|
|
64
64
|
if (polygon) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
var polygonFeature = JSON.parse(JSON.stringify(polygon));
|
|
66
|
+
polygonFeature.properties.type = 'shop-custom';
|
|
67
|
+
polygonFeature.properties.poi_id = feature.properties.id;
|
|
68
|
+
polygonFeature.properties.amenity = feature.properties.amenity;
|
|
69
|
+
polygonFeature.id = JSON.stringify(key);
|
|
70
|
+
featuresToAdd_1.push(polygonFeature);
|
|
71
|
+
if (polygonFeature.properties['label-line'] &&
|
|
72
|
+
polygonFeature.properties['label-line'][0] instanceof Array &&
|
|
73
|
+
polygonFeature.properties['label-line'][1] instanceof Array) {
|
|
72
74
|
var labelLineFeature = JSON.parse(JSON.stringify(feature));
|
|
73
75
|
labelLineFeature.geometry = {
|
|
74
|
-
coordinates:
|
|
76
|
+
coordinates: polygonFeature.properties['label-line'],
|
|
75
77
|
type: 'LineString',
|
|
76
78
|
};
|
|
77
79
|
labelLineFeature.properties.id = JSON.stringify(key + 9999);
|
|
78
80
|
labelLineFeature.id = JSON.stringify(key + 9999);
|
|
79
81
|
labelLineFeature.properties.type = 'shop-label';
|
|
80
|
-
|
|
82
|
+
polygonFeature.properties.label_id = labelLineFeature.properties.id;
|
|
81
83
|
featuresToAdd_1.push(labelLineFeature);
|
|
82
84
|
}
|
|
83
85
|
}
|
package/lib/models/style.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export default class StyleModel {
|
|
|
36
36
|
addSource(sourceId: string, source: any): void;
|
|
37
37
|
getSources(): BaseSource[];
|
|
38
38
|
setSource(id: string, data: BaseSource): void;
|
|
39
|
+
getSource(sourceId: string): BaseSource;
|
|
39
40
|
setLevel(level: number): void;
|
|
40
41
|
get polygonEditing(): any;
|
|
41
42
|
toggleCluster(): void;
|
package/lib/models/style.js
CHANGED
|
@@ -268,6 +268,9 @@ var StyleModel = /** @class */ (function () {
|
|
|
268
268
|
StyleModel.prototype.setSource = function (id, data) {
|
|
269
269
|
this.sources[id] = data.source;
|
|
270
270
|
};
|
|
271
|
+
StyleModel.prototype.getSource = function (sourceId) {
|
|
272
|
+
return this.sources[sourceId];
|
|
273
|
+
};
|
|
271
274
|
StyleModel.prototype.setLevel = function (level) {
|
|
272
275
|
__spreadArray(__spreadArray([], this.getLayers('main')), this.getLayers('route')).forEach(function (layer) {
|
|
273
276
|
if (!layer.filter) {
|