proximiio-js-library 1.15.2 → 1.16.0

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 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} newly added 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.
@@ -328,7 +328,9 @@ export declare class Map {
328
328
  private initUrlParams;
329
329
  private featureDialog;
330
330
  private onAddNewFeature;
331
+ private onUpdateFeaturesBatch;
331
332
  private onUpdateFeature;
333
+ private updateFeatureData;
332
334
  private onDeleteFeature;
333
335
  private onFeaturesChange;
334
336
  private onSetFeatureFilter;
@@ -1009,6 +1011,46 @@ export declare class Map {
1009
1011
  }, title?: string, level?: number, lat?: number, lng?: number, icon?: string, placeId?: string, floorId?: string, properties?: {
1010
1012
  [key: string]: string | number | boolean | null | undefined;
1011
1013
  }, isTemporary?: boolean): Promise<Feature>;
1014
+ /**
1015
+ * Update existing map features in batch.
1016
+ * @memberof Map
1017
+ * @name updateFeatures
1018
+ * @param features { array } Array of feature objects
1019
+ * @param feature.id { string } Feature ID (string)
1020
+ * @param feature.title {string} feature title, optional
1021
+ * @param feature.level {number} feature floor level, optional
1022
+ * @param feature.lat {number} feature latitude coordinate, optional
1023
+ * @param feature.lng {number} feature longitude coordinate, optional
1024
+ * @param feature.icon {string} feature icon image in base64 format, optional
1025
+ * @param feature.placeId {string} feature place_id, optional
1026
+ * @param feature.floorId {string} feature floor_id, optional
1027
+ * @param feature.properties {object} feature properties, optional
1028
+ * @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
1029
+ * @return <Promise>{Feature} newly added feature
1030
+ * @example
1031
+ * const map = new Proximiio.Map();
1032
+ * map.getMapReadyListener().subscribe(ready => {
1033
+ * console.log('map ready', ready);
1034
+ *
1035
+ * 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});
1036
+ * });
1037
+ */
1038
+ updateFeatures(options: {
1039
+ features: {
1040
+ id: string;
1041
+ title?: string;
1042
+ level?: number;
1043
+ lat?: number;
1044
+ lng?: number;
1045
+ icon?: string;
1046
+ placeId?: string;
1047
+ floorId?: string;
1048
+ properties?: {
1049
+ [key: string]: string | number | boolean | null | undefined;
1050
+ };
1051
+ }[];
1052
+ isTemporary?: boolean;
1053
+ }): Promise<Feature[]>;
1012
1054
  /**
1013
1055
  * Delete existing map feature.
1014
1056
  * @memberof Map
@@ -1057,7 +1099,7 @@ export declare class Map {
1057
1099
  * console.log('feature updated', feature);
1058
1100
  * });
1059
1101
  */
1060
- getFeatureUpdateListener(): CustomSubject<Feature>;
1102
+ getFeatureUpdateListener(): CustomSubject<Feature | Feature[]>;
1061
1103
  /**
1062
1104
  * @memberof Map
1063
1105
  * @name getFeatureDeleteListener
@@ -2314,7 +2314,66 @@ export class Map {
2314
2314
  return featureVar;
2315
2315
  });
2316
2316
  }
2317
+ onUpdateFeaturesBatch({ features, isTemporary = true, }) {
2318
+ var _a;
2319
+ return __awaiter(this, void 0, void 0, function* () {
2320
+ const featureVars = yield Promise.all(features.map((f) => this.updateFeatureData(Object.assign(Object.assign({}, f), { isTemporary }))));
2321
+ for (const featureVar of featureVars) {
2322
+ const newIcon = (_a = features.find((f) => f.id === featureVar.id)) === null || _a === void 0 ? void 0 : _a.icon;
2323
+ if (newIcon && newIcon.length > 0) {
2324
+ const decodedIcon = yield getImageFromBase64(newIcon);
2325
+ this.map.addImage(featureVar.id, decodedIcon);
2326
+ this.amenityIds.push(featureVar.id);
2327
+ this.filteredAmenities.push(featureVar.id);
2328
+ }
2329
+ this.filterOutFeatures();
2330
+ this.geojsonSource.update(featureVar);
2331
+ }
2332
+ if (!isTemporary) {
2333
+ yield addFeatures({
2334
+ type: 'FeatureCollection',
2335
+ features: featureVars.map((f) => f.JsonDynamicStrip),
2336
+ });
2337
+ }
2338
+ this.onFeaturesChange();
2339
+ this.onFeatureUpdateListener.next(featureVars);
2340
+ return featureVars;
2341
+ });
2342
+ }
2317
2343
  onUpdateFeature({ id, title, level, lat, lng, icon, placeId, floorId, properties, isTemporary = true, }) {
2344
+ return __awaiter(this, void 0, void 0, function* () {
2345
+ const featureVar = yield this.updateFeatureData({
2346
+ id,
2347
+ title,
2348
+ level,
2349
+ lat,
2350
+ lng,
2351
+ icon,
2352
+ placeId,
2353
+ floorId,
2354
+ properties,
2355
+ isTemporary,
2356
+ });
2357
+ if (icon && icon.length > 0) {
2358
+ const decodedIcon = yield getImageFromBase64(icon);
2359
+ this.map.addImage(id, decodedIcon);
2360
+ this.amenityIds.push(id);
2361
+ this.filteredAmenities.push(id);
2362
+ this.filterOutFeatures();
2363
+ }
2364
+ if (!isTemporary) {
2365
+ yield addFeatures({
2366
+ type: 'FeatureCollection',
2367
+ features: [featureVar.JsonDynamicStrip],
2368
+ });
2369
+ }
2370
+ this.geojsonSource.update(featureVar);
2371
+ this.onFeaturesChange();
2372
+ this.onFeatureUpdateListener.next(featureVar);
2373
+ return featureVar;
2374
+ });
2375
+ }
2376
+ updateFeatureData({ id, title, level, lat, lng, icon, placeId, floorId, properties, isTemporary = true, }) {
2318
2377
  return __awaiter(this, void 0, void 0, function* () {
2319
2378
  const foundFeature = this.state.allFeatures.features.find((f) => f.id === id || f.properties.id === id);
2320
2379
  const polygonLayer = this.defaultOptions.polygonLayers.find((l) => l.featureType === (properties === null || properties === void 0 ? void 0 : properties.type));
@@ -2333,43 +2392,17 @@ export class Map {
2333
2392
  if (polygonLayer) {
2334
2393
  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
2394
  }
2336
- if (icon && icon.length > 0) {
2337
- const decodedIcon = yield getImageFromBase64(icon);
2338
- this.map.addImage(id, decodedIcon);
2339
- this.amenityIds.push(id);
2340
- this.filteredAmenities.push(id);
2341
- this.filterOutFeatures();
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);
2395
+ const featureIndex = this.state.features.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
2396
+ const optimizedFeatureIndex = this.state.optimizedFeatures.features.findIndex((x) => x.id === featureVar.id || x.properties.id === featureVar.id);
2397
+ if (featureIndex !== -1)
2398
+ this.state.features.features[featureIndex] = featureVar;
2399
+ if (optimizedFeatureIndex !== -1)
2400
+ this.state.optimizedFeatures.features[optimizedFeatureIndex] = featureVar;
2401
+ if (isTemporary) {
2358
2402
  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
2403
  if (dynamicIndex !== -1)
2364
2404
  this.state.dynamicFeatures.features[dynamicIndex] = featureVar;
2365
2405
  }
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
2406
  return featureVar;
2374
2407
  });
2375
2408
  }
@@ -5295,6 +5328,35 @@ export class Map {
5295
5328
  return yield this.onUpdateFeature(opts);
5296
5329
  });
5297
5330
  }
5331
+ /**
5332
+ * Update existing map features in batch.
5333
+ * @memberof Map
5334
+ * @name updateFeatures
5335
+ * @param features { array } Array of feature objects
5336
+ * @param feature.id { string } Feature ID (string)
5337
+ * @param feature.title {string} feature title, optional
5338
+ * @param feature.level {number} feature floor level, optional
5339
+ * @param feature.lat {number} feature latitude coordinate, optional
5340
+ * @param feature.lng {number} feature longitude coordinate, optional
5341
+ * @param feature.icon {string} feature icon image in base64 format, optional
5342
+ * @param feature.placeId {string} feature place_id, optional
5343
+ * @param feature.floorId {string} feature floor_id, optional
5344
+ * @param feature.properties {object} feature properties, optional
5345
+ * @param isTemporary {boolean} will update feature just temporary, it's not saved to db, optional, default
5346
+ * @return <Promise>{Feature} newly added feature
5347
+ * @example
5348
+ * const map = new Proximiio.Map();
5349
+ * map.getMapReadyListener().subscribe(ready => {
5350
+ * console.log('map ready', ready);
5351
+ *
5352
+ * 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});
5353
+ * });
5354
+ */
5355
+ updateFeatures(options) {
5356
+ return __awaiter(this, void 0, void 0, function* () {
5357
+ return yield this.onUpdateFeaturesBatch(options);
5358
+ });
5359
+ }
5298
5360
  /**
5299
5361
  * Delete existing map feature.
5300
5362
  * @memberof Map
@@ -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
  }
@@ -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
  }