proximiio-js-library 1.8.3 → 1.8.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.
@@ -332,12 +332,15 @@ var Map = /** @class */ (function () {
332
332
  return [4 /*yield*/, this.onPlaceSelect(this.state.place, this.defaultOptions.zoomIntoPlace)];
333
333
  case 5:
334
334
  _c.sent();
335
- if (this.defaultOptions.initPolygons) {
336
- this.initPolygons();
335
+ if (this.defaultOptions.useRasterTiles) {
336
+ this.initRasterTiles();
337
337
  }
338
338
  if (this.defaultOptions.isKiosk) {
339
339
  this.initKiosk();
340
340
  }
341
+ if (this.defaultOptions.initPolygons) {
342
+ this.initPolygons();
343
+ }
341
344
  if (this.defaultOptions.useGpsLocation) {
342
345
  this.initGeoLocation();
343
346
  }
@@ -350,9 +353,6 @@ var Map = /** @class */ (function () {
350
353
  if (this.defaultOptions.animatedRoute) {
351
354
  this.initAnimatedRoute();
352
355
  }
353
- if (this.defaultOptions.useRasterTiles) {
354
- this.initRasterTiles();
355
- }
356
356
  this.initPersonsMap();
357
357
  this.map.on('click', 'proximiio-pois-icons', function (ev) {
358
358
  _this.onShopClick(ev);
@@ -364,6 +364,7 @@ var Map = /** @class */ (function () {
364
364
  if (this.defaultOptions.handleUrlParams) {
365
365
  this.initUrlParams();
366
366
  }
367
+ this.map.setStyle(this.state.style);
367
368
  _c.label = 6;
368
369
  case 6: return [2 /*return*/];
369
370
  }
@@ -394,7 +395,6 @@ var Map = /** @class */ (function () {
394
395
  },
395
396
  filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
396
397
  });
397
- this.map.setStyle(this.state.style);
398
398
  this.centerOnPoi(this.startPoint);
399
399
  }
400
400
  }
@@ -466,7 +466,6 @@ var Map = /** @class */ (function () {
466
466
  },
467
467
  filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
468
468
  });
469
- this.map.setStyle(this.state.style);
470
469
  }
471
470
  };
472
471
  Map.prototype.initAnimatedRoute = function () {
@@ -490,7 +489,6 @@ var Map = /** @class */ (function () {
490
489
  },
491
490
  filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
492
491
  });
493
- this.map.setStyle(this.state.style);
494
492
  }
495
493
  };
496
494
  Map.prototype.initRasterTiles = function () {
@@ -511,10 +509,9 @@ var Map = /** @class */ (function () {
511
509
  source: 'raster-tiles',
512
510
  minzoom: this.defaultOptions.rasterTilesOptions.minZoom ? this.defaultOptions.rasterTilesOptions.minZoom : 15,
513
511
  maxzoom: this.defaultOptions.rasterTilesOptions.maxZoom ? this.defaultOptions.rasterTilesOptions.maxZoom : 22,
514
- }, this.defaultOptions.rasterTilesOptions.maxZoom
512
+ }, this.defaultOptions.rasterTilesOptions.beforeLayer
515
513
  ? this.defaultOptions.rasterTilesOptions.beforeLayer
516
514
  : 'proximiio-shop');
517
- this.map.setStyle(this.state.style);
518
515
  }
519
516
  };
520
517
  Map.prototype.initPolygons = function () {
@@ -526,7 +523,6 @@ var Map = /** @class */ (function () {
526
523
  this.state.style.addLayer(custom_layers_1.PolygonIconsLayer.json);
527
524
  custom_layers_1.PolygonTitlesLayer.setFilterLevel(this.state.floor.level);
528
525
  this.state.style.addLayer(custom_layers_1.PolygonTitlesLayer.json);
529
- this.map.setStyle(this.state.style);
530
526
  this.map.on('click', 'shop-custom', function (e) {
531
527
  _this.onShopClick(e);
532
528
  });
@@ -1058,44 +1054,41 @@ var Map = /** @class */ (function () {
1058
1054
  this.activePolygonsAmenity = amenityId;
1059
1055
  };
1060
1056
  Map.prototype.handlePoiVisibility = function () {
1061
- var _this = this;
1062
1057
  // proximiio-pois-icons, proximiio-pois-labels, 'pois-icons', 'pois-labels'
1063
1058
  var layers = ['proximiio-pois-icons', 'proximiio-pois-labels', 'pois-icons', 'pois-labels'];
1064
1059
  if (this.defaultOptions.initPolygons) {
1065
1060
  layers.push('poi-custom-icons', 'shop-labels');
1066
1061
  }
1067
- layers.forEach(function (layer) {
1068
- if (_this.map.getLayer(layer)) {
1069
- setTimeout(function () {
1070
- var l = _this.map.getLayer(layer);
1071
- var filters = __spreadArray([], l.filter);
1072
- var visibilityFilter = filters.findIndex(function (f) { return f[1][1] === 'visibility'; });
1073
- if (visibilityFilter !== -1) {
1074
- // toggle pois visibility based on visibility param
1075
- if (filters[visibilityFilter][0] === '!=') {
1076
- // show all pois, the visibility params is not considered
1077
- filters[visibilityFilter] = [
1078
- 'match',
1079
- ['get', 'visibility'],
1080
- ['visible', 'hidden', 'undefined'],
1081
- true,
1082
- false,
1083
- ];
1084
- }
1085
- else {
1086
- // hide pois with hidden visibility
1087
- filters[visibilityFilter] = ['!=', ['get', 'visibility'], 'hidden'];
1088
- }
1089
- }
1090
- else {
1091
- // add visibility filter
1092
- filters.push(['!=', ['get', 'visibility'], 'hidden']);
1093
- }
1094
- _this.state.style.getLayer(layer).filter = filters;
1095
- _this.map.setFilter(layer, filters);
1096
- });
1097
- }
1098
- });
1062
+ /*layers.forEach((layer) => {
1063
+ if (this.map.getLayer(layer)) {
1064
+ setTimeout(() => {
1065
+ const l = this.map.getLayer(layer) as any;
1066
+ const filters = [...l.filter];
1067
+ const visibilityFilter = filters.findIndex((f) => f[1][1] === 'visibility');
1068
+ if (visibilityFilter !== -1) {
1069
+ // toggle pois visibility based on visibility param
1070
+ if (filters[visibilityFilter][0] === '!=') {
1071
+ // show all pois, the visibility params is not considered
1072
+ filters[visibilityFilter] = [
1073
+ 'match',
1074
+ ['get', 'visibility'],
1075
+ ['visible', 'hidden', 'undefined'],
1076
+ true,
1077
+ false,
1078
+ ];
1079
+ } else {
1080
+ // hide pois with hidden visibility
1081
+ filters[visibilityFilter] = ['!=', ['get', 'visibility'], 'hidden'];
1082
+ }
1083
+ } else {
1084
+ // add visibility filter
1085
+ filters.push(['!=', ['get', 'visibility'], 'hidden']);
1086
+ }
1087
+ this.state.style.getLayer(layer).filter = filters;
1088
+ this.map.setFilter(layer, filters);
1089
+ });
1090
+ }
1091
+ });*/
1099
1092
  this.state.style.notify('filter-change');
1100
1093
  };
1101
1094
  Map.prototype.onToggleHiddenPois = function () {
@@ -1147,7 +1140,6 @@ var Map = /** @class */ (function () {
1147
1140
  type: 'FeatureCollection',
1148
1141
  features: personsCollection,
1149
1142
  };
1150
- this.map.setStyle(this.state.style);
1151
1143
  this.onPersonUpdateListener.next(this.state.persons);
1152
1144
  };
1153
1145
  Map.prototype.prepareStyle = function (style) {
@@ -1534,8 +1526,11 @@ var Map = /** @class */ (function () {
1534
1526
  var _this = this;
1535
1527
  if (this.routingSource.lines && this.routingSource.route) {
1536
1528
  var currentRouteIndex = this.routingSource.lines.findIndex(function (route) { return +route.properties.level === _this.state.floor.level; });
1537
- var currentRoute = this.routingSource.lines[currentRouteIndex];
1538
- var nextRouteIndex = way === 'up' ? currentRouteIndex + 1 : currentRouteIndex - 1;
1529
+ var currentRoute_1 = this.routingSource.lines[currentRouteIndex];
1530
+ var nextRouteIndex = this.routingSource.lines.findIndex(function (route) {
1531
+ return +route.properties.level ===
1532
+ (way === 'up' ? currentRoute_1.properties.level + 1 : currentRoute_1.properties.level - 1);
1533
+ });
1539
1534
  var nextRoute = this.routingSource.lines[nextRouteIndex];
1540
1535
  // return currentRouteIndex !== -1 && nextRoute ? +nextRoute.properties.level : way === 'up' ? this.state.floor.level + 1 : this.state.floor.level - 1;
1541
1536
  return nextRoute &&
@@ -43,12 +43,13 @@ var Routing = /** @class */ (function () {
43
43
  }
44
44
  };
45
45
  Routing.prototype.route = function (start, finish) {
46
- var points = this.wayfinding.runAStar(start, finish).map(function (i) {
47
- return new feature_1.default(i);
48
- });
46
+ var points = this.wayfinding.runAStar(start, finish);
49
47
  if (!points) {
50
48
  return null;
51
49
  }
50
+ points = points.map(function (i) {
51
+ return new feature_1.default(i);
52
+ });
52
53
  var pathPoints = {};
53
54
  var pathPartIndex = 0;
54
55
  points.forEach(function (p, index) {
@@ -79,13 +79,13 @@ var RoutingSource = /** @class */ (function (_super) {
79
79
  if (start && finish) {
80
80
  this.notify('loading-start');
81
81
  route = this.routing.route(start, finish);
82
- paths = route.paths;
82
+ paths = route === null || route === void 0 ? void 0 : route.paths;
83
83
  // @ts-ignore
84
- this.route = route.paths;
84
+ this.route = route === null || route === void 0 ? void 0 : route.paths;
85
85
  // @ts-ignore
86
- this.points = route.points;
87
- this.levelPaths = route.levelPaths;
88
- this.levelPoints = route.levelPoints;
86
+ this.points = route === null || route === void 0 ? void 0 : route.points;
87
+ this.levelPaths = route === null || route === void 0 ? void 0 : route.levelPaths;
88
+ this.levelPoints = route === null || route === void 0 ? void 0 : route.levelPoints;
89
89
  if (paths) {
90
90
  lines = [];
91
91
  for (_i = 0, _a = Object.entries(paths); _i < _a.length; _i++) {
@@ -29,7 +29,7 @@ export default class StyleModel {
29
29
  getUniversalLayers(source: string): any[];
30
30
  getSyntheticLayers(): any[];
31
31
  usesPrefixes(): boolean;
32
- addLayer(layer: any): void;
32
+ addLayer(layer: any, beforeLayer: string): void;
33
33
  getLayer(id: string): any;
34
34
  getLayerIndex(id: string): number;
35
35
  getLayers(sourceId: string): BaseLayer[];
@@ -235,8 +235,13 @@ var StyleModel = /** @class */ (function () {
235
235
  StyleModel.prototype.usesPrefixes = function () {
236
236
  return typeof this.layers.find(function (layer) { return layer.id === 'proximiio-paths'; }) !== 'undefined';
237
237
  };
238
- StyleModel.prototype.addLayer = function (layer) {
239
- this.layers.push(layer);
238
+ StyleModel.prototype.addLayer = function (layer, beforeLayer) {
239
+ if (beforeLayer) {
240
+ this.layers.splice(this.getLayerIndex(beforeLayer) + 1, 0, layer);
241
+ }
242
+ else {
243
+ this.layers.push(layer);
244
+ }
240
245
  };
241
246
  StyleModel.prototype.getLayer = function (id) {
242
247
  return this.layers.find(function (layer) { return layer.id === id; });