proximiio-js-library 1.15.2 → 1.16.1
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 +42 -1
- package/lib/components/map/main.d.ts +45 -2
- package/lib/components/map/main.js +103 -37
- package/lib/models/kiosk.d.ts +2 -0
- package/lib/models/kiosk.js +4 -0
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -863,7 +863,7 @@ Update existing map feature.
|
|
|
863
863
|
// @param floorId {string} feature floor_id, optional
|
|
864
864
|
// @param properties {object} feature properties, optional
|
|
865
865
|
// @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
|
|
866
|
-
// @return <Promise>{Feature}
|
|
866
|
+
// @return <Promise>{Feature} updated feature
|
|
867
867
|
|
|
868
868
|
map.getMapReadyListener().subscribe((ready) => {
|
|
869
869
|
console.log('map ready', ready);
|
|
@@ -877,6 +877,47 @@ map.getMapReadyListener().subscribe((ready) => {
|
|
|
877
877
|
});
|
|
878
878
|
```
|
|
879
879
|
|
|
880
|
+
##### Update Features
|
|
881
|
+
|
|
882
|
+
Update existing map features in batch.
|
|
883
|
+
|
|
884
|
+
```javascript
|
|
885
|
+
// @param features {array} Array of feature objects
|
|
886
|
+
// @param feature.id {string} feature id
|
|
887
|
+
// @param feature.title {string} feature title, optional
|
|
888
|
+
// @param feature.level {number} feature floor level, optional
|
|
889
|
+
// @param feature.lat {number} feature latitude coordinate, optional
|
|
890
|
+
// @param feature.lng {number} feature longitude coordinate, optional
|
|
891
|
+
// @param feature.icon {string} feature icon image in base64 format, optional
|
|
892
|
+
// @param feature.placeId {string} feature place_id, optional
|
|
893
|
+
// @param feature.floorId {string} feature floor_id, optional
|
|
894
|
+
// @param feature.properties {object} feature properties, optional
|
|
895
|
+
// @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
|
|
896
|
+
// @return <Promise>{Feature} updates features
|
|
897
|
+
|
|
898
|
+
map.getMapReadyListener().subscribe((ready) => {
|
|
899
|
+
console.log('map ready', ready);
|
|
900
|
+
const myFeature = map.updateFeatures({
|
|
901
|
+
features: [
|
|
902
|
+
{
|
|
903
|
+
id: 'poiId',
|
|
904
|
+
title: 'myPOI',
|
|
905
|
+
level: 0,
|
|
906
|
+
lat: 48.606703739771774,
|
|
907
|
+
lng: 17.8330923845066,
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
id: 'poiId 2',
|
|
911
|
+
title: 'myPOI 2',
|
|
912
|
+
level: 0,
|
|
913
|
+
lat: 48.606705739771774,
|
|
914
|
+
lng: 17.8330933845066,
|
|
915
|
+
},
|
|
916
|
+
],
|
|
917
|
+
});
|
|
918
|
+
});
|
|
919
|
+
```
|
|
920
|
+
|
|
880
921
|
##### Delete Feature
|
|
881
922
|
|
|
882
923
|
Delete existing map feature.
|
|
@@ -112,6 +112,7 @@ export interface Options {
|
|
|
112
112
|
pointColor?: string;
|
|
113
113
|
pointOutline?: boolean;
|
|
114
114
|
labelFont?: string | string[];
|
|
115
|
+
parkingKiosk?: boolean;
|
|
115
116
|
};
|
|
116
117
|
initPolygons?: boolean;
|
|
117
118
|
polygonsOptions?: PolygonOptions;
|
|
@@ -328,7 +329,9 @@ export declare class Map {
|
|
|
328
329
|
private initUrlParams;
|
|
329
330
|
private featureDialog;
|
|
330
331
|
private onAddNewFeature;
|
|
332
|
+
private onUpdateFeaturesBatch;
|
|
331
333
|
private onUpdateFeature;
|
|
334
|
+
private updateFeatureData;
|
|
332
335
|
private onDeleteFeature;
|
|
333
336
|
private onFeaturesChange;
|
|
334
337
|
private onSetFeatureFilter;
|
|
@@ -1009,6 +1012,46 @@ export declare class Map {
|
|
|
1009
1012
|
}, title?: string, level?: number, lat?: number, lng?: number, icon?: string, placeId?: string, floorId?: string, properties?: {
|
|
1010
1013
|
[key: string]: string | number | boolean | null | undefined;
|
|
1011
1014
|
}, isTemporary?: boolean): Promise<Feature>;
|
|
1015
|
+
/**
|
|
1016
|
+
* Update existing map features in batch.
|
|
1017
|
+
* @memberof Map
|
|
1018
|
+
* @name updateFeatures
|
|
1019
|
+
* @param features { array } Array of feature objects
|
|
1020
|
+
* @param feature.id { string } Feature ID (string)
|
|
1021
|
+
* @param feature.title {string} feature title, optional
|
|
1022
|
+
* @param feature.level {number} feature floor level, optional
|
|
1023
|
+
* @param feature.lat {number} feature latitude coordinate, optional
|
|
1024
|
+
* @param feature.lng {number} feature longitude coordinate, optional
|
|
1025
|
+
* @param feature.icon {string} feature icon image in base64 format, optional
|
|
1026
|
+
* @param feature.placeId {string} feature place_id, optional
|
|
1027
|
+
* @param feature.floorId {string} feature floor_id, optional
|
|
1028
|
+
* @param feature.properties {object} feature properties, optional
|
|
1029
|
+
* @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
|
|
1030
|
+
* @return <Promise>{Feature} newly added feature
|
|
1031
|
+
* @example
|
|
1032
|
+
* const map = new Proximiio.Map();
|
|
1033
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1034
|
+
* console.log('map ready', ready);
|
|
1035
|
+
*
|
|
1036
|
+
* map.updateFeatures({features: [{id: 'poiId', title: 'myPOI', level: 0, lat: 48.606703739771774, lng:17.833092384506614}, {id: 'poiId2', title: 'myPOI 2', level: 0, lat: 48.606803739771774, lng:17.833022384506614}], isTemporary: true});
|
|
1037
|
+
* });
|
|
1038
|
+
*/
|
|
1039
|
+
updateFeatures(options: {
|
|
1040
|
+
features: {
|
|
1041
|
+
id: string;
|
|
1042
|
+
title?: string;
|
|
1043
|
+
level?: number;
|
|
1044
|
+
lat?: number;
|
|
1045
|
+
lng?: number;
|
|
1046
|
+
icon?: string;
|
|
1047
|
+
placeId?: string;
|
|
1048
|
+
floorId?: string;
|
|
1049
|
+
properties?: {
|
|
1050
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
1051
|
+
};
|
|
1052
|
+
}[];
|
|
1053
|
+
isTemporary?: boolean;
|
|
1054
|
+
}): Promise<Feature[]>;
|
|
1012
1055
|
/**
|
|
1013
1056
|
* Delete existing map feature.
|
|
1014
1057
|
* @memberof Map
|
|
@@ -1057,7 +1100,7 @@ export declare class Map {
|
|
|
1057
1100
|
* console.log('feature updated', feature);
|
|
1058
1101
|
* });
|
|
1059
1102
|
*/
|
|
1060
|
-
getFeatureUpdateListener(): CustomSubject<Feature>;
|
|
1103
|
+
getFeatureUpdateListener(): CustomSubject<Feature | Feature[]>;
|
|
1061
1104
|
/**
|
|
1062
1105
|
* @memberof Map
|
|
1063
1106
|
* @name getFeatureDeleteListener
|
|
@@ -1089,7 +1132,7 @@ export declare class Map {
|
|
|
1089
1132
|
* map.setKiosk(48.606703739771774, 17.833092384506614, 0);
|
|
1090
1133
|
* });
|
|
1091
1134
|
*/
|
|
1092
|
-
setKiosk(lat: number, lng: number, level: number): void;
|
|
1135
|
+
setKiosk(lat: number, lng: number, level: number, parkingKiosk?: boolean): void;
|
|
1093
1136
|
/**
|
|
1094
1137
|
* This method will stop kiosk behaviour.
|
|
1095
1138
|
* @memberof Map
|
|
@@ -1129,9 +1129,10 @@ export class Map {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
|
-
onSetKiosk(lat, lng, level) {
|
|
1132
|
+
onSetKiosk(lat, lng, level, parkingKiosk = false) {
|
|
1133
1133
|
if (this.map && this.defaultOptions.isKiosk) {
|
|
1134
|
-
this.defaultOptions.kioskSettings = Object.assign(Object.assign({}, this.defaultOptions.kioskSettings), { coordinates: [lng, lat], level
|
|
1134
|
+
this.defaultOptions.kioskSettings = Object.assign(Object.assign({}, this.defaultOptions.kioskSettings), { coordinates: [lng, lat], level,
|
|
1135
|
+
parkingKiosk });
|
|
1135
1136
|
this.startPoint = point(this.defaultOptions.kioskSettings.coordinates, {
|
|
1136
1137
|
level: this.defaultOptions.kioskSettings.level,
|
|
1137
1138
|
});
|
|
@@ -1894,6 +1895,9 @@ export class Map {
|
|
|
1894
1895
|
}
|
|
1895
1896
|
onShopClick(e) {
|
|
1896
1897
|
var _a, _b, _c;
|
|
1898
|
+
if (this.defaultOptions.isKiosk && this.defaultOptions.kioskSettings.parkingKiosk) {
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1897
1901
|
if (!this.defaultOptions.blockFeatureClickWhileRouting ||
|
|
1898
1902
|
(this.defaultOptions.blockFeatureClickWhileRouting &&
|
|
1899
1903
|
!this.routingSource.route &&
|
|
@@ -2314,7 +2318,66 @@ export class Map {
|
|
|
2314
2318
|
return featureVar;
|
|
2315
2319
|
});
|
|
2316
2320
|
}
|
|
2321
|
+
onUpdateFeaturesBatch({ features, isTemporary = true, }) {
|
|
2322
|
+
var _a;
|
|
2323
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2324
|
+
const featureVars = yield Promise.all(features.map((f) => this.updateFeatureData(Object.assign(Object.assign({}, f), { isTemporary }))));
|
|
2325
|
+
for (const featureVar of featureVars) {
|
|
2326
|
+
const newIcon = (_a = features.find((f) => f.id === featureVar.id)) === null || _a === void 0 ? void 0 : _a.icon;
|
|
2327
|
+
if (newIcon && newIcon.length > 0) {
|
|
2328
|
+
const decodedIcon = yield getImageFromBase64(newIcon);
|
|
2329
|
+
this.map.addImage(featureVar.id, decodedIcon);
|
|
2330
|
+
this.amenityIds.push(featureVar.id);
|
|
2331
|
+
this.filteredAmenities.push(featureVar.id);
|
|
2332
|
+
}
|
|
2333
|
+
this.filterOutFeatures();
|
|
2334
|
+
this.geojsonSource.update(featureVar);
|
|
2335
|
+
}
|
|
2336
|
+
if (!isTemporary) {
|
|
2337
|
+
yield addFeatures({
|
|
2338
|
+
type: 'FeatureCollection',
|
|
2339
|
+
features: featureVars.map((f) => f.JsonDynamicStrip),
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2342
|
+
this.onFeaturesChange();
|
|
2343
|
+
this.onFeatureUpdateListener.next(featureVars);
|
|
2344
|
+
return featureVars;
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2317
2347
|
onUpdateFeature({ id, title, level, lat, lng, icon, placeId, floorId, properties, isTemporary = true, }) {
|
|
2348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2349
|
+
const featureVar = yield this.updateFeatureData({
|
|
2350
|
+
id,
|
|
2351
|
+
title,
|
|
2352
|
+
level,
|
|
2353
|
+
lat,
|
|
2354
|
+
lng,
|
|
2355
|
+
icon,
|
|
2356
|
+
placeId,
|
|
2357
|
+
floorId,
|
|
2358
|
+
properties,
|
|
2359
|
+
isTemporary,
|
|
2360
|
+
});
|
|
2361
|
+
if (icon && icon.length > 0) {
|
|
2362
|
+
const decodedIcon = yield getImageFromBase64(icon);
|
|
2363
|
+
this.map.addImage(id, decodedIcon);
|
|
2364
|
+
this.amenityIds.push(id);
|
|
2365
|
+
this.filteredAmenities.push(id);
|
|
2366
|
+
this.filterOutFeatures();
|
|
2367
|
+
}
|
|
2368
|
+
if (!isTemporary) {
|
|
2369
|
+
yield addFeatures({
|
|
2370
|
+
type: 'FeatureCollection',
|
|
2371
|
+
features: [featureVar.JsonDynamicStrip],
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
this.geojsonSource.update(featureVar);
|
|
2375
|
+
this.onFeaturesChange();
|
|
2376
|
+
this.onFeatureUpdateListener.next(featureVar);
|
|
2377
|
+
return featureVar;
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
updateFeatureData({ id, title, level, lat, lng, icon, placeId, floorId, properties, isTemporary = true, }) {
|
|
2318
2381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2319
2382
|
const foundFeature = this.state.allFeatures.features.find((f) => f.id === id || f.properties.id === id);
|
|
2320
2383
|
const polygonLayer = this.defaultOptions.polygonLayers.find((l) => l.featureType === (properties === null || properties === void 0 ? void 0 : properties.type));
|
|
@@ -2333,43 +2396,17 @@ export class Map {
|
|
|
2333
2396
|
if (polygonLayer) {
|
|
2334
2397
|
featureVar.properties = Object.assign(Object.assign({}, featureVar.properties), { dynamic_minZoom: polygonLayer.minZoom, dynamic_maxZoom: polygonLayer.maxZoom, dynamic_selectedHeight: polygonLayer.selectedPolygonHeight, dynamic_hoverHeight: polygonLayer.hoverPolygonHeight, dynamic_activeHeight: polygonLayer.activePolygonHeight || polygonLayer.hoverPolygonHeight, dynamic_disabledHeight: polygonLayer.disabledPolygonHeight, dynamic_defaultHeight: polygonLayer.defaultPolygonHeight, dynamic_base: polygonLayer.base, dynamic_selectedColor: polygonLayer.selectedPolygonColor, dynamic_hoverColor: polygonLayer.hoverPolygonColor, dynamic_activeColor: polygonLayer.activePolygonColor || polygonLayer.hoverPolygonColor, dynamic_disabledColor: polygonLayer.disabledPolygonColor, dynamic_defaultColor: polygonLayer.defaultPolygonColor });
|
|
2335
2398
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
this.
|
|
2340
|
-
|
|
2341
|
-
this.
|
|
2342
|
-
|
|
2343
|
-
if (!isTemporary) {
|
|
2344
|
-
const featureIndex = this.state.features.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2345
|
-
const optimizedFeatureIndex = this.state.optimizedFeatures.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2346
|
-
if (featureIndex)
|
|
2347
|
-
this.state.features.features[featureIndex] = featureVar;
|
|
2348
|
-
if (optimizedFeatureIndex)
|
|
2349
|
-
this.state.optimizedFeatures.features[optimizedFeatureIndex] = featureVar;
|
|
2350
|
-
yield addFeatures({
|
|
2351
|
-
type: 'FeatureCollection',
|
|
2352
|
-
features: [featureVar.JsonDynamicStrip],
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
else {
|
|
2356
|
-
const featureIndex = this.state.features.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2357
|
-
const optimizedFeatureIndex = this.state.optimizedFeatures.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2399
|
+
const featureIndex = this.state.features.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2400
|
+
const optimizedFeatureIndex = this.state.optimizedFeatures.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2401
|
+
if (featureIndex !== -1)
|
|
2402
|
+
this.state.features.features[featureIndex] = featureVar;
|
|
2403
|
+
if (optimizedFeatureIndex !== -1)
|
|
2404
|
+
this.state.optimizedFeatures.features[optimizedFeatureIndex] = featureVar;
|
|
2405
|
+
if (isTemporary) {
|
|
2358
2406
|
const dynamicIndex = this.state.dynamicFeatures.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
|
|
2359
|
-
if (featureIndex !== -1)
|
|
2360
|
-
this.state.features.features[featureIndex] = featureVar;
|
|
2361
|
-
if (optimizedFeatureIndex !== -1)
|
|
2362
|
-
this.state.optimizedFeatures.features[optimizedFeatureIndex] = featureVar;
|
|
2363
2407
|
if (dynamicIndex !== -1)
|
|
2364
2408
|
this.state.dynamicFeatures.features[dynamicIndex] = featureVar;
|
|
2365
2409
|
}
|
|
2366
|
-
// this.state.allFeatures.features = [...this.state.features.features, ...this.state.dynamicFeatures.features]; // this is not probably updated with non dynamic feature update TODO
|
|
2367
|
-
this.geojsonSource.update(featureVar);
|
|
2368
|
-
// this.onSourceChange();
|
|
2369
|
-
// this.routingSource.routing.setData(this.state.allFeatures);
|
|
2370
|
-
// this.updateMapSource(this.routingSource);
|
|
2371
|
-
this.onFeaturesChange();
|
|
2372
|
-
this.onFeatureUpdateListener.next(featureVar);
|
|
2373
2410
|
return featureVar;
|
|
2374
2411
|
});
|
|
2375
2412
|
}
|
|
@@ -5295,6 +5332,35 @@ export class Map {
|
|
|
5295
5332
|
return yield this.onUpdateFeature(opts);
|
|
5296
5333
|
});
|
|
5297
5334
|
}
|
|
5335
|
+
/**
|
|
5336
|
+
* Update existing map features in batch.
|
|
5337
|
+
* @memberof Map
|
|
5338
|
+
* @name updateFeatures
|
|
5339
|
+
* @param features { array } Array of feature objects
|
|
5340
|
+
* @param feature.id { string } Feature ID (string)
|
|
5341
|
+
* @param feature.title {string} feature title, optional
|
|
5342
|
+
* @param feature.level {number} feature floor level, optional
|
|
5343
|
+
* @param feature.lat {number} feature latitude coordinate, optional
|
|
5344
|
+
* @param feature.lng {number} feature longitude coordinate, optional
|
|
5345
|
+
* @param feature.icon {string} feature icon image in base64 format, optional
|
|
5346
|
+
* @param feature.placeId {string} feature place_id, optional
|
|
5347
|
+
* @param feature.floorId {string} feature floor_id, optional
|
|
5348
|
+
* @param feature.properties {object} feature properties, optional
|
|
5349
|
+
* @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
|
|
5350
|
+
* @return <Promise>{Feature} newly added feature
|
|
5351
|
+
* @example
|
|
5352
|
+
* const map = new Proximiio.Map();
|
|
5353
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
5354
|
+
* console.log('map ready', ready);
|
|
5355
|
+
*
|
|
5356
|
+
* map.updateFeatures({features: [{id: 'poiId', title: 'myPOI', level: 0, lat: 48.606703739771774, lng:17.833092384506614}, {id: 'poiId2', title: 'myPOI 2', level: 0, lat: 48.606803739771774, lng:17.833022384506614}], isTemporary: true});
|
|
5357
|
+
* });
|
|
5358
|
+
*/
|
|
5359
|
+
updateFeatures(options) {
|
|
5360
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5361
|
+
return yield this.onUpdateFeaturesBatch(options);
|
|
5362
|
+
});
|
|
5363
|
+
}
|
|
5298
5364
|
/**
|
|
5299
5365
|
* Delete existing map feature.
|
|
5300
5366
|
* @memberof Map
|
|
@@ -5385,13 +5451,13 @@ export class Map {
|
|
|
5385
5451
|
* map.setKiosk(48.606703739771774, 17.833092384506614, 0);
|
|
5386
5452
|
* });
|
|
5387
5453
|
*/
|
|
5388
|
-
setKiosk(lat, lng, level) {
|
|
5454
|
+
setKiosk(lat, lng, level, parkingKiosk = false) {
|
|
5389
5455
|
if (!this.defaultOptions.isKiosk) {
|
|
5390
5456
|
this.defaultOptions.isKiosk = true;
|
|
5391
5457
|
this.initKiosk();
|
|
5392
5458
|
}
|
|
5393
5459
|
if (this.defaultOptions.isKiosk) {
|
|
5394
|
-
this.onSetKiosk(lat, lng, level);
|
|
5460
|
+
this.onSetKiosk(lat, lng, level, parkingKiosk);
|
|
5395
5461
|
}
|
|
5396
5462
|
else {
|
|
5397
5463
|
throw new Error(`Map is not initiated as kiosk`);
|
package/lib/models/kiosk.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare class KioskModel extends BaseModel {
|
|
|
11
11
|
pitch?: number;
|
|
12
12
|
bounds?: [[number, number], [number, number]];
|
|
13
13
|
floor_id?: string;
|
|
14
|
+
parkingKiosk?: boolean;
|
|
14
15
|
constructor(data: any);
|
|
15
16
|
get hasLocation(): boolean;
|
|
17
|
+
get isParkingKiosk(): boolean;
|
|
16
18
|
}
|
package/lib/models/kiosk.js
CHANGED
|
@@ -10,8 +10,12 @@ export class KioskModel extends BaseModel {
|
|
|
10
10
|
this.pitch = data.pitch;
|
|
11
11
|
this.bounds = data.bounds;
|
|
12
12
|
this.floor_id = data.floor_id;
|
|
13
|
+
this.parkingKiosk = data.parkingKiosk ? data.parkingKiosk : false;
|
|
13
14
|
}
|
|
14
15
|
get hasLocation() {
|
|
15
16
|
return !isNaN(this.coordinates.lat) && !isNaN(this.coordinates.lng);
|
|
16
17
|
}
|
|
18
|
+
get isParkingKiosk() {
|
|
19
|
+
return this.parkingKiosk;
|
|
20
|
+
}
|
|
17
21
|
}
|