proximiio-js-library 1.2.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 +719 -0
- package/assets/proximiio-js-library.css +520 -0
- package/assets/tbtnav.js +3 -0
- package/assets/wayfinding.d.ts +3 -0
- package/assets/wayfinding.js +1586 -0
- package/lib/common.d.ts +7 -0
- package/lib/common.js +49 -0
- package/lib/components/map/constants.d.ts +6 -0
- package/lib/components/map/constants.js +30 -0
- package/lib/components/map/custom-layers.d.ts +5 -0
- package/lib/components/map/custom-layers.js +74 -0
- package/lib/components/map/icons.d.ts +23 -0
- package/lib/components/map/icons.js +64 -0
- package/lib/components/map/layers/any_layer.d.ts +9 -0
- package/lib/components/map/layers/any_layer.js +2 -0
- package/lib/components/map/layers/background_layer.d.ts +16 -0
- package/lib/components/map/layers/background_layer.js +52 -0
- package/lib/components/map/layers/base_layer.d.ts +18 -0
- package/lib/components/map/layers/base_layer.js +127 -0
- package/lib/components/map/layers/circle_layer.d.ts +25 -0
- package/lib/components/map/layers/circle_layer.js +62 -0
- package/lib/components/map/layers/fill_extrusion_layer.d.ts +21 -0
- package/lib/components/map/layers/fill_extrusion_layer.js +57 -0
- package/lib/components/map/layers/fill_layer.d.ts +21 -0
- package/lib/components/map/layers/fill_layer.js +57 -0
- package/lib/components/map/layers/heatmap_layer.d.ts +18 -0
- package/lib/components/map/layers/heatmap_layer.js +54 -0
- package/lib/components/map/layers/hillshade_layer.d.ts +19 -0
- package/lib/components/map/layers/hillshade_layer.js +55 -0
- package/lib/components/map/layers/line_layer.d.ts +28 -0
- package/lib/components/map/layers/line_layer.js +64 -0
- package/lib/components/map/layers/raster_layer.d.ts +21 -0
- package/lib/components/map/layers/raster_layer.js +57 -0
- package/lib/components/map/layers/symbol_layer.d.ts +71 -0
- package/lib/components/map/layers/symbol_layer.js +153 -0
- package/lib/components/map/main.d.ts +625 -0
- package/lib/components/map/main.js +1765 -0
- package/lib/components/map/metadata.d.ts +134 -0
- package/lib/components/map/metadata.js +135 -0
- package/lib/components/map/routing.d.ts +12 -0
- package/lib/components/map/routing.js +74 -0
- package/lib/components/map/sources/base_source.d.ts +10 -0
- package/lib/components/map/sources/base_source.js +38 -0
- package/lib/components/map/sources/cluster_source.d.ts +7 -0
- package/lib/components/map/sources/cluster_source.js +30 -0
- package/lib/components/map/sources/data_source.d.ts +17 -0
- package/lib/components/map/sources/data_source.js +46 -0
- package/lib/components/map/sources/geojson_source.d.ts +16 -0
- package/lib/components/map/sources/geojson_source.js +77 -0
- package/lib/components/map/sources/image_source_manager.d.ts +16 -0
- package/lib/components/map/sources/image_source_manager.js +131 -0
- package/lib/components/map/sources/routing_source.d.ts +22 -0
- package/lib/components/map/sources/routing_source.js +131 -0
- package/lib/components/map/sources/synthetic_source.d.ts +7 -0
- package/lib/components/map/sources/synthetic_source.js +32 -0
- package/lib/components/map/sources/vector_source.d.ts +8 -0
- package/lib/components/map/sources/vector_source.js +31 -0
- package/lib/components/select/main.d.ts +66 -0
- package/lib/components/select/main.js +195 -0
- package/lib/controllers/auth.d.ts +48 -0
- package/lib/controllers/auth.js +156 -0
- package/lib/controllers/floors.d.ts +14 -0
- package/lib/controllers/floors.js +105 -0
- package/lib/controllers/geo.d.ts +10 -0
- package/lib/controllers/geo.js +131 -0
- package/lib/controllers/places.d.ts +14 -0
- package/lib/controllers/places.js +108 -0
- package/lib/controllers/repository.d.ts +24 -0
- package/lib/controllers/repository.js +68 -0
- package/lib/controllers/style.d.ts +4 -0
- package/lib/controllers/style.js +76 -0
- package/lib/eventable.d.ts +7 -0
- package/lib/eventable.js +29 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +14 -0
- package/lib/models/amenity.d.ts +11 -0
- package/lib/models/amenity.js +41 -0
- package/lib/models/auth-data.d.ts +4 -0
- package/lib/models/auth-data.js +2 -0
- package/lib/models/base.d.ts +7 -0
- package/lib/models/base.js +18 -0
- package/lib/models/feature.d.ts +46 -0
- package/lib/models/feature.js +277 -0
- package/lib/models/floor.d.ts +30 -0
- package/lib/models/floor.js +51 -0
- package/lib/models/geopoint.d.ts +6 -0
- package/lib/models/geopoint.js +2 -0
- package/lib/models/mapbox-options.d.ts +171 -0
- package/lib/models/mapbox-options.js +2 -0
- package/lib/models/person.d.ts +8 -0
- package/lib/models/person.js +18 -0
- package/lib/models/place.d.ts +14 -0
- package/lib/models/place.js +40 -0
- package/lib/models/poi_type.d.ts +19 -0
- package/lib/models/poi_type.js +25 -0
- package/lib/models/style.d.ts +53 -0
- package/lib/models/style.js +424 -0
- package/lib/proximiio.js +2 -0
- package/lib/proximiio.js.LICENSE.txt +79 -0
- package/package.json +61 -0
|
@@ -0,0 +1,1765 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
50
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
51
|
+
to[j] = from[i];
|
|
52
|
+
return to;
|
|
53
|
+
};
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.Map = exports.globalState = void 0;
|
|
56
|
+
var mapboxgl = require("mapbox-gl");
|
|
57
|
+
var repository_1 = require("../../controllers/repository");
|
|
58
|
+
var place_1 = require("../../models/place");
|
|
59
|
+
var floor_1 = require("../../models/floor");
|
|
60
|
+
var style_1 = require("../../models/style");
|
|
61
|
+
var geojson_source_1 = require("./sources/geojson_source");
|
|
62
|
+
var synthetic_source_1 = require("./sources/synthetic_source");
|
|
63
|
+
var feature_1 = require("../../models/feature");
|
|
64
|
+
var routing_source_1 = require("./sources/routing_source");
|
|
65
|
+
var cluster_source_1 = require("./sources/cluster_source");
|
|
66
|
+
var image_source_manager_1 = require("./sources/image_source_manager");
|
|
67
|
+
var common_1 = require("../../common");
|
|
68
|
+
var icons_1 = require("./icons");
|
|
69
|
+
var floors_1 = require("../../controllers/floors");
|
|
70
|
+
var places_1 = require("../../controllers/places");
|
|
71
|
+
var rxjs_1 = require("rxjs");
|
|
72
|
+
var turf = require("@turf/turf");
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
var tingle = require("tingle.js/dist/tingle");
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
var TBTNav = require("../../../assets/tbtnav");
|
|
77
|
+
var constants_1 = require("./constants");
|
|
78
|
+
var custom_layers_1 = require("./custom-layers");
|
|
79
|
+
var person_1 = require("../../models/person");
|
|
80
|
+
exports.globalState = {
|
|
81
|
+
initializing: true,
|
|
82
|
+
floor: new floor_1.FloorModel({}),
|
|
83
|
+
floors: [],
|
|
84
|
+
place: new place_1.PlaceModel({}),
|
|
85
|
+
places: [],
|
|
86
|
+
style: new style_1.default({}),
|
|
87
|
+
styles: [],
|
|
88
|
+
amenities: [],
|
|
89
|
+
features: new feature_1.FeatureCollection({}),
|
|
90
|
+
dynamicFeatures: new feature_1.FeatureCollection({}),
|
|
91
|
+
allFeatures: new feature_1.FeatureCollection({}),
|
|
92
|
+
latitude: 0,
|
|
93
|
+
longitude: 0,
|
|
94
|
+
loadingRoute: false,
|
|
95
|
+
noPlaces: false,
|
|
96
|
+
textNavigation: null,
|
|
97
|
+
persons: [],
|
|
98
|
+
};
|
|
99
|
+
var Map = /** @class */ (function () {
|
|
100
|
+
function Map(options) {
|
|
101
|
+
this.geojsonSource = new geojson_source_1.default(new feature_1.FeatureCollection({}));
|
|
102
|
+
this.syntheticSource = new synthetic_source_1.default(new feature_1.FeatureCollection({}));
|
|
103
|
+
this.routingSource = new routing_source_1.default();
|
|
104
|
+
this.clusterSource = new cluster_source_1.default();
|
|
105
|
+
this.imageSourceManager = new image_source_manager_1.default();
|
|
106
|
+
this.onMapReadyListener = new rxjs_1.Subject();
|
|
107
|
+
this.onPlaceSelectListener = new rxjs_1.Subject();
|
|
108
|
+
this.onFloorSelectListener = new rxjs_1.Subject();
|
|
109
|
+
this.onRouteFoundListener = new rxjs_1.Subject();
|
|
110
|
+
this.onRouteFailedListener = new rxjs_1.Subject();
|
|
111
|
+
this.onRouteCancelListener = new rxjs_1.Subject();
|
|
112
|
+
this.onFeatureAddListener = new rxjs_1.Subject();
|
|
113
|
+
this.onFeatureUpdateListener = new rxjs_1.Subject();
|
|
114
|
+
this.onFeatureDeleteListener = new rxjs_1.Subject();
|
|
115
|
+
this.onPolygonClickListener = new rxjs_1.Subject();
|
|
116
|
+
this.onPersonUpdateListener = new rxjs_1.Subject();
|
|
117
|
+
this.defaultOptions = {
|
|
118
|
+
selector: 'proximiioMap',
|
|
119
|
+
allowNewFeatureModal: false,
|
|
120
|
+
newFeatureModalEvent: 'click',
|
|
121
|
+
enableTBTNavigation: true,
|
|
122
|
+
zoomIntoPlace: true,
|
|
123
|
+
isKiosk: false,
|
|
124
|
+
initPolygons: false,
|
|
125
|
+
};
|
|
126
|
+
this.showStartPoint = false;
|
|
127
|
+
this.amenityIds = [];
|
|
128
|
+
this.filteredAmenities = [];
|
|
129
|
+
this.amenityFilters = [];
|
|
130
|
+
this.amenityCategories = {};
|
|
131
|
+
// fix centering in case of kiosk with defined pitch/bearing/etc. in mapbox options
|
|
132
|
+
if (options.isKiosk && options.mapboxOptions && options.kioskSettings && !options.mapboxOptions.center) {
|
|
133
|
+
options.mapboxOptions.center = options.kioskSettings.coordinates;
|
|
134
|
+
}
|
|
135
|
+
this.defaultOptions = __assign(__assign({}, this.defaultOptions), options);
|
|
136
|
+
this.state = exports.globalState;
|
|
137
|
+
this.onSourceChange = this.onSourceChange.bind(this);
|
|
138
|
+
this.onSyntheticChange = this.onSyntheticChange.bind(this);
|
|
139
|
+
this.onStyleChange = this.onStyleChange.bind(this);
|
|
140
|
+
this.onStyleSelect = this.onStyleSelect.bind(this);
|
|
141
|
+
this.onRouteUpdate = this.onRouteUpdate.bind(this);
|
|
142
|
+
this.onRouteChange = this.onRouteChange.bind(this);
|
|
143
|
+
this.onRouteCancel = this.onRouteCancel.bind(this);
|
|
144
|
+
this.map = new mapboxgl.Map(__assign(__assign({}, this.defaultOptions.mapboxOptions), { container: this.defaultOptions.selector ? this.defaultOptions.selector : 'map' }));
|
|
145
|
+
this.initialize();
|
|
146
|
+
}
|
|
147
|
+
Map.prototype.initialize = function () {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
this.geojsonSource.on(this.onSourceChange);
|
|
153
|
+
this.syntheticSource.on(this.onSyntheticChange);
|
|
154
|
+
this.routingSource.on(this.onRouteChange);
|
|
155
|
+
return [4 /*yield*/, this.fetch()];
|
|
156
|
+
case 1:
|
|
157
|
+
_a.sent();
|
|
158
|
+
return [2 /*return*/];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
Map.prototype.cancelObservers = function () {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
this.geojsonSource.off(this.onSourceChange);
|
|
167
|
+
this.syntheticSource.off(this.onSyntheticChange);
|
|
168
|
+
this.state.style.off(this.onStyleChange);
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
Map.prototype.fetch = function () {
|
|
174
|
+
var _a, _b, _c;
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var _d, places, style, styles, features, amenities, defaultPlace, place, center;
|
|
177
|
+
var _this = this;
|
|
178
|
+
return __generator(this, function (_e) {
|
|
179
|
+
switch (_e.label) {
|
|
180
|
+
case 0: return [4 /*yield*/, repository_1.default.getPackage(this.defaultOptions.initPolygons)];
|
|
181
|
+
case 1:
|
|
182
|
+
_d = _e.sent(), places = _d.places, style = _d.style, styles = _d.styles, features = _d.features, amenities = _d.amenities;
|
|
183
|
+
defaultPlace = places.find(function (p) { return p.id === _this.defaultOptions.defaultPlaceId; });
|
|
184
|
+
place = places.length > 0 ? (defaultPlace ? defaultPlace : places[0]) : new place_1.PlaceModel({});
|
|
185
|
+
center = ((_a = this.defaultOptions.mapboxOptions) === null || _a === void 0 ? void 0 : _a.center)
|
|
186
|
+
? this.defaultOptions.mapboxOptions.center
|
|
187
|
+
: this.defaultOptions.isKiosk
|
|
188
|
+
? (_b = this.defaultOptions.kioskSettings) === null || _b === void 0 ? void 0 : _b.coordinates
|
|
189
|
+
: [place.location.lng, place.location.lat];
|
|
190
|
+
style.center = center;
|
|
191
|
+
this.geojsonSource.fetch(features);
|
|
192
|
+
this.routingSource.routing.setData(new feature_1.FeatureCollection(features));
|
|
193
|
+
this.prepareStyle(style);
|
|
194
|
+
this.imageSourceManager.belowLayer = style.usesPrefixes() ? 'proximiio-floors' : 'floors';
|
|
195
|
+
this.imageSourceManager.initialize();
|
|
196
|
+
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: (_c = this.defaultOptions.mapboxOptions) === null || _c === void 0 ? void 0 : _c.zoom, noPlaces: places.length === 0 });
|
|
197
|
+
style.on(this.onStyleChange);
|
|
198
|
+
this.map.setStyle(this.state.style);
|
|
199
|
+
this.map.on('load', function (e) {
|
|
200
|
+
_this.onMapReady(e);
|
|
201
|
+
});
|
|
202
|
+
if (this.defaultOptions.allowNewFeatureModal) {
|
|
203
|
+
this.map.on(this.defaultOptions.newFeatureModalEvent ? this.defaultOptions.newFeatureModalEvent : 'dblclick', function (e) {
|
|
204
|
+
_this.featureDialog(e);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (this.defaultOptions.enableTBTNavigation) {
|
|
208
|
+
this.routeFactory = new TBTNav.RouteFactory(JSON.stringify(this.state.allFeatures.features), 'en');
|
|
209
|
+
}
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
Map.prototype.onMapReady = function (e) {
|
|
216
|
+
var _a, _b;
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var map, routingLayer, usePrefixed, shopsLayer, decodedChevron, decodedPersonIcon;
|
|
219
|
+
return __generator(this, function (_c) {
|
|
220
|
+
switch (_c.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
map = e.target;
|
|
223
|
+
if (!map) return [3 /*break*/, 4];
|
|
224
|
+
(_a = this.state.style) === null || _a === void 0 ? void 0 : _a.togglePaths(true);
|
|
225
|
+
routingLayer = map.getLayer('routing-line-completed');
|
|
226
|
+
usePrefixed = typeof routingLayer === 'undefined' && typeof map.getLayer('proximiio-routing-line-completed') !== 'undefined';
|
|
227
|
+
shopsLayer = map.getLayer('shops');
|
|
228
|
+
if (usePrefixed) {
|
|
229
|
+
map.moveLayer('proximiio-routing-line-completed', 'proximiio-outer_wall');
|
|
230
|
+
map.moveLayer('proximiio-routing-line-remaining', 'proximiio-outer_wall');
|
|
231
|
+
map.moveLayer('proximiio-paths', 'routing-line-completed');
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (routingLayer) {
|
|
235
|
+
if (shopsLayer) {
|
|
236
|
+
map.moveLayer('routing-line-completed', 'proximiio-routing-symbols');
|
|
237
|
+
map.moveLayer('routing-line-remaining', 'proximiio-routing-symbols');
|
|
238
|
+
}
|
|
239
|
+
map.moveLayer('proximiio-paths', 'routing-line-completed');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
map.setMaxZoom(30);
|
|
243
|
+
return [4 /*yield*/, common_1.getImageFromBase64(icons_1.chevron)];
|
|
244
|
+
case 1:
|
|
245
|
+
decodedChevron = _c.sent();
|
|
246
|
+
return [4 /*yield*/, common_1.getImageFromBase64(icons_1.person)];
|
|
247
|
+
case 2:
|
|
248
|
+
decodedPersonIcon = _c.sent();
|
|
249
|
+
map.addImage('chevron_right', decodedChevron);
|
|
250
|
+
map.addImage('pulsing-dot', icons_1.pulsingDot, { pixelRatio: 2 });
|
|
251
|
+
map.addImage('person', decodedPersonIcon);
|
|
252
|
+
this.onSourceChange();
|
|
253
|
+
this.updateMapSource(this.geojsonSource);
|
|
254
|
+
this.updateMapSource(this.routingSource);
|
|
255
|
+
this.updateCluster();
|
|
256
|
+
this.updateImages();
|
|
257
|
+
this.filteredAmenities = this.amenityIds;
|
|
258
|
+
this.imageSourceManager.setLevel(map, (_b = this.state.floor) === null || _b === void 0 ? void 0 : _b.level);
|
|
259
|
+
return [4 /*yield*/, this.onPlaceSelect(this.state.place, this.defaultOptions.zoomIntoPlace)];
|
|
260
|
+
case 3:
|
|
261
|
+
_c.sent();
|
|
262
|
+
if (this.defaultOptions.initPolygons) {
|
|
263
|
+
this.initPolygons();
|
|
264
|
+
}
|
|
265
|
+
if (this.defaultOptions.isKiosk) {
|
|
266
|
+
this.initKiosk();
|
|
267
|
+
}
|
|
268
|
+
this.initPersonsMap();
|
|
269
|
+
this.onMapReadyListener.next(true);
|
|
270
|
+
_c.label = 4;
|
|
271
|
+
case 4: return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
Map.prototype.initKiosk = function () {
|
|
277
|
+
if (this.map) {
|
|
278
|
+
this.showStartPoint = false;
|
|
279
|
+
if (this.defaultOptions.kioskSettings) {
|
|
280
|
+
this.startPoint = turf.point(this.defaultOptions.kioskSettings.coordinates, {
|
|
281
|
+
level: this.defaultOptions.kioskSettings.level,
|
|
282
|
+
});
|
|
283
|
+
this.showStartPoint = true;
|
|
284
|
+
this.state.style.addSource('my-location', {
|
|
285
|
+
type: 'geojson',
|
|
286
|
+
data: {
|
|
287
|
+
type: 'FeatureCollection',
|
|
288
|
+
features: [this.startPoint],
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
this.state.style.addLayer({
|
|
292
|
+
id: 'my-location-layer',
|
|
293
|
+
type: 'symbol',
|
|
294
|
+
source: 'my-location',
|
|
295
|
+
layout: {
|
|
296
|
+
'icon-image': 'pulsing-dot',
|
|
297
|
+
},
|
|
298
|
+
filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
|
|
299
|
+
});
|
|
300
|
+
this.map.setStyle(this.state.style);
|
|
301
|
+
this.centerOnPoi(this.startPoint);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
Map.prototype.onSetKiosk = function (lat, lng, level) {
|
|
306
|
+
if (this.map && this.defaultOptions.isKiosk) {
|
|
307
|
+
this.defaultOptions.kioskSettings = {
|
|
308
|
+
coordinates: [lng, lat],
|
|
309
|
+
level: level,
|
|
310
|
+
};
|
|
311
|
+
this.startPoint = turf.point(this.defaultOptions.kioskSettings.coordinates, {
|
|
312
|
+
level: this.defaultOptions.kioskSettings.level,
|
|
313
|
+
});
|
|
314
|
+
this.state.style.sources['my-location'].data = {
|
|
315
|
+
type: 'FeatureCollection',
|
|
316
|
+
features: [this.startPoint],
|
|
317
|
+
};
|
|
318
|
+
this.map.setFilter('my-location-layer', ['all', ['==', ['to-number', ['get', 'level']], level]]);
|
|
319
|
+
this.map.setStyle(this.state.style);
|
|
320
|
+
this.centerOnPoi(this.startPoint);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
Map.prototype.initPolygons = function () {
|
|
324
|
+
var _this = this;
|
|
325
|
+
if (this.map) {
|
|
326
|
+
custom_layers_1.PolygonsLayer.setFilterLevel(this.state.floor.level);
|
|
327
|
+
this.state.style.addLayer(custom_layers_1.PolygonsLayer.json);
|
|
328
|
+
custom_layers_1.PolygonIconsLayer.setFilterLevel(this.state.floor.level);
|
|
329
|
+
this.state.style.addLayer(custom_layers_1.PolygonIconsLayer.json);
|
|
330
|
+
custom_layers_1.PolygonTitlesLayer.setFilterLevel(this.state.floor.level);
|
|
331
|
+
this.state.style.addLayer(custom_layers_1.PolygonTitlesLayer.json);
|
|
332
|
+
this.map.setStyle(this.state.style);
|
|
333
|
+
this.map.on('click', 'shop-custom', function (e) {
|
|
334
|
+
_this.onShopClick(e);
|
|
335
|
+
});
|
|
336
|
+
this.map.on('mouseenter', 'shop-custom', function () {
|
|
337
|
+
_this.onShopMouseEnter();
|
|
338
|
+
});
|
|
339
|
+
this.map.on('mousemove', 'shop-custom', function (e) {
|
|
340
|
+
_this.onShopMouseMove(e);
|
|
341
|
+
});
|
|
342
|
+
this.map.on('mouseleave', 'shop-custom', function (e) {
|
|
343
|
+
_this.onShopMouseLeave(e);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
Map.prototype.onShopClick = function (e) {
|
|
348
|
+
if (e.features && e.features[0] && e.features[0].properties) {
|
|
349
|
+
// @ts-ignore
|
|
350
|
+
var poi = this.state.allFeatures.features.find(function (i) { return i.properties.id === e.features[0].properties.poi_id; });
|
|
351
|
+
this.onPolygonClickListener.next(poi);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
Map.prototype.handlePolygonSelection = function (poi) {
|
|
355
|
+
var connectedPolygonId = poi && poi.properties.metadata ? poi.properties.metadata.polygon_id : null;
|
|
356
|
+
if (this.selectedPolygon) {
|
|
357
|
+
this.map.setFeatureState({
|
|
358
|
+
source: 'main',
|
|
359
|
+
id: this.selectedPolygon.id,
|
|
360
|
+
}, {
|
|
361
|
+
selected: false,
|
|
362
|
+
});
|
|
363
|
+
if (this.selectedPolygon.properties.label_id) {
|
|
364
|
+
this.map.setFeatureState({
|
|
365
|
+
source: 'main',
|
|
366
|
+
id: this.selectedPolygon.properties.label_id,
|
|
367
|
+
}, {
|
|
368
|
+
selected: false,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (connectedPolygonId) {
|
|
373
|
+
this.selectedPolygon = this.state.allFeatures.features.find(function (i) { return i.properties.id === connectedPolygonId; });
|
|
374
|
+
this.map.setFeatureState({
|
|
375
|
+
source: 'main',
|
|
376
|
+
id: this.selectedPolygon.id,
|
|
377
|
+
}, {
|
|
378
|
+
selected: true,
|
|
379
|
+
});
|
|
380
|
+
if (this.selectedPolygon.properties.label_id) {
|
|
381
|
+
this.map.setFeatureState({
|
|
382
|
+
source: 'main',
|
|
383
|
+
id: this.selectedPolygon.properties.label_id,
|
|
384
|
+
}, {
|
|
385
|
+
selected: true,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
Map.prototype.onShopMouseEnter = function () {
|
|
391
|
+
this.map.getCanvas().style.cursor = 'pointer';
|
|
392
|
+
};
|
|
393
|
+
Map.prototype.onShopMouseMove = function (e) {
|
|
394
|
+
if (e.features && e.features.length > 0) {
|
|
395
|
+
if (this.hoveredPolygon) {
|
|
396
|
+
this.map.setFeatureState({
|
|
397
|
+
source: 'main',
|
|
398
|
+
id: this.hoveredPolygon.id,
|
|
399
|
+
}, {
|
|
400
|
+
hover: false,
|
|
401
|
+
});
|
|
402
|
+
if (this.hoveredPolygon.properties.label_id) {
|
|
403
|
+
this.map.setFeatureState({
|
|
404
|
+
source: 'main',
|
|
405
|
+
id: this.hoveredPolygon.properties.label_id,
|
|
406
|
+
}, {
|
|
407
|
+
hover: false,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
this.hoveredPolygon = e.features[0];
|
|
412
|
+
this.map.setFeatureState({
|
|
413
|
+
source: 'main',
|
|
414
|
+
id: this.hoveredPolygon.id,
|
|
415
|
+
}, {
|
|
416
|
+
hover: true,
|
|
417
|
+
});
|
|
418
|
+
if (this.hoveredPolygon.properties.label_id) {
|
|
419
|
+
this.map.setFeatureState({
|
|
420
|
+
source: 'main',
|
|
421
|
+
id: this.hoveredPolygon.properties.label_id,
|
|
422
|
+
}, {
|
|
423
|
+
hover: true,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
Map.prototype.onShopMouseLeave = function (e) {
|
|
429
|
+
this.map.getCanvas().style.cursor = '';
|
|
430
|
+
if (this.hoveredPolygon) {
|
|
431
|
+
this.map.setFeatureState({
|
|
432
|
+
source: 'main',
|
|
433
|
+
id: this.hoveredPolygon.id,
|
|
434
|
+
}, {
|
|
435
|
+
hover: false,
|
|
436
|
+
});
|
|
437
|
+
if (this.hoveredPolygon.properties.label_id) {
|
|
438
|
+
this.map.setFeatureState({
|
|
439
|
+
source: 'main',
|
|
440
|
+
id: this.hoveredPolygon.properties.label_id,
|
|
441
|
+
}, {
|
|
442
|
+
hover: false,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
this.hoveredPolygon = null;
|
|
447
|
+
};
|
|
448
|
+
Map.prototype.featureDialog = function (e) {
|
|
449
|
+
var _this = this;
|
|
450
|
+
var _a;
|
|
451
|
+
var features = this.map.queryRenderedFeatures(e.point, { layers: ['proximiio-pois-icons'] });
|
|
452
|
+
var edit = features.length > 0;
|
|
453
|
+
var modal = new tingle.modal({
|
|
454
|
+
footer: true,
|
|
455
|
+
stickyFooter: false,
|
|
456
|
+
closeMethods: ['overlay', 'button', 'escape'],
|
|
457
|
+
closeLabel: 'Close',
|
|
458
|
+
onClose: function () {
|
|
459
|
+
modal.destroy();
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
// set content
|
|
463
|
+
modal.setContent(edit ? constants_1.EDIT_FEATURE_DIALOG(e, features[0]) : constants_1.NEW_FEATURE_DIALOG(e, (_a = this.state.floor) === null || _a === void 0 ? void 0 : _a.level));
|
|
464
|
+
modal.addFooterBtn('Submit', 'tingle-btn tingle-btn--primary', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
465
|
+
var formData, data, _a;
|
|
466
|
+
var _b;
|
|
467
|
+
return __generator(this, function (_c) {
|
|
468
|
+
switch (_c.label) {
|
|
469
|
+
case 0:
|
|
470
|
+
formData = new FormData(document.querySelector('#modal-form'));
|
|
471
|
+
_b = {
|
|
472
|
+
id: "" + formData.get('id'),
|
|
473
|
+
title: "" + formData.get('title'),
|
|
474
|
+
level: formData.get('level'),
|
|
475
|
+
lat: formData.get('lat'),
|
|
476
|
+
lng: formData.get('lng')
|
|
477
|
+
};
|
|
478
|
+
if (!formData.get('icon').size) return [3 /*break*/, 2];
|
|
479
|
+
return [4 /*yield*/, common_1.getBase64FromImage(formData.get('icon'))];
|
|
480
|
+
case 1:
|
|
481
|
+
_a = _c.sent();
|
|
482
|
+
return [3 /*break*/, 3];
|
|
483
|
+
case 2:
|
|
484
|
+
_a = undefined;
|
|
485
|
+
_c.label = 3;
|
|
486
|
+
case 3:
|
|
487
|
+
data = (_b.icon = _a,
|
|
488
|
+
_b);
|
|
489
|
+
if (!(data.title && data.level && data.lat && data.lng)) return [3 /*break*/, 8];
|
|
490
|
+
if (!edit) return [3 /*break*/, 5];
|
|
491
|
+
return [4 /*yield*/, this.onUpdateFeature(data.id, data.title, +data.level, +data.lat, +data.lng, data.icon)];
|
|
492
|
+
case 4:
|
|
493
|
+
_c.sent();
|
|
494
|
+
return [3 /*break*/, 7];
|
|
495
|
+
case 5: return [4 /*yield*/, this.onAddNewFeature(data.title, +data.level, +data.lat, +data.lng, data.icon, data.id)];
|
|
496
|
+
case 6:
|
|
497
|
+
_c.sent();
|
|
498
|
+
_c.label = 7;
|
|
499
|
+
case 7:
|
|
500
|
+
modal.close();
|
|
501
|
+
return [3 /*break*/, 9];
|
|
502
|
+
case 8:
|
|
503
|
+
alert('Please fill all the required fields!');
|
|
504
|
+
_c.label = 9;
|
|
505
|
+
case 9: return [2 /*return*/];
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}); });
|
|
509
|
+
if (edit) {
|
|
510
|
+
modal.addFooterBtn('Delete', 'tingle-btn tingle-btn--danger', function () {
|
|
511
|
+
var _a, _b;
|
|
512
|
+
_this.onDeleteFeature((_b = (_a = features[0]) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.id);
|
|
513
|
+
modal.close();
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
modal.addFooterBtn('Cancel', 'tingle-btn tingle-btn--default tingle-btn--pull-right', function () {
|
|
517
|
+
modal.close();
|
|
518
|
+
});
|
|
519
|
+
modal.open();
|
|
520
|
+
};
|
|
521
|
+
Map.prototype.onAddNewFeature = function (title, level, lat, lng, icon, id, placeId, floorId) {
|
|
522
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
523
|
+
var featureId, feature, decodedIcon;
|
|
524
|
+
return __generator(this, function (_a) {
|
|
525
|
+
switch (_a.label) {
|
|
526
|
+
case 0:
|
|
527
|
+
featureId = id ? id : common_1.uuidv4();
|
|
528
|
+
if (this.state.allFeatures.features.findIndex(function (f) { return f.id === featureId || f.properties.id === featureId; }) > 0) {
|
|
529
|
+
console.error("Create feature failed: Feature with id '" + featureId + "' already exists!");
|
|
530
|
+
throw new Error("Create feature failed: Feature with id '" + featureId + "' already exists!");
|
|
531
|
+
}
|
|
532
|
+
feature = new feature_1.default({
|
|
533
|
+
type: 'Feature',
|
|
534
|
+
id: featureId,
|
|
535
|
+
geometry: new feature_1.Geometry({
|
|
536
|
+
type: 'Point',
|
|
537
|
+
coordinates: [lng, lat],
|
|
538
|
+
}),
|
|
539
|
+
properties: {
|
|
540
|
+
type: 'poi',
|
|
541
|
+
usecase: 'poi',
|
|
542
|
+
id: featureId,
|
|
543
|
+
minzoom: 15,
|
|
544
|
+
visibility: 'visible',
|
|
545
|
+
amenity: icon ? id : 'default',
|
|
546
|
+
title: title,
|
|
547
|
+
level: level,
|
|
548
|
+
images: [icon],
|
|
549
|
+
place_id: placeId,
|
|
550
|
+
floor_id: floorId,
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
if (!(icon && icon.length > 0)) return [3 /*break*/, 2];
|
|
554
|
+
return [4 /*yield*/, common_1.getImageFromBase64(icon)];
|
|
555
|
+
case 1:
|
|
556
|
+
decodedIcon = _a.sent();
|
|
557
|
+
this.map.addImage(featureId, decodedIcon);
|
|
558
|
+
_a.label = 2;
|
|
559
|
+
case 2:
|
|
560
|
+
this.state.dynamicFeatures.features.push(feature);
|
|
561
|
+
// this.state.allFeatures.features = [...this.state.features.features, ...this.state.dynamicFeatures.features];
|
|
562
|
+
this.geojsonSource.create(feature);
|
|
563
|
+
// this.onSourceChange();
|
|
564
|
+
// this.routingSource.routing.setData(this.state.allFeatures);
|
|
565
|
+
// this.updateMapSource(this.routingSource);
|
|
566
|
+
this.onFeaturesChange();
|
|
567
|
+
this.onFeatureAddListener.next(feature);
|
|
568
|
+
return [2 /*return*/, feature];
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
Map.prototype.onUpdateFeature = function (id, title, level, lat, lng, icon, placeId, floorId) {
|
|
574
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
575
|
+
var foundFeature, feature, decodedIcon, dynamicIndex;
|
|
576
|
+
return __generator(this, function (_a) {
|
|
577
|
+
switch (_a.label) {
|
|
578
|
+
case 0:
|
|
579
|
+
foundFeature = this.state.allFeatures.features.find(function (f) { return f.id === id || f.properties.id === id; });
|
|
580
|
+
if (!foundFeature) {
|
|
581
|
+
console.error("Update feature failed: Feature with id '" + id + "' has not been found!");
|
|
582
|
+
throw new Error("Update feature failed: Feature with id '" + id + "' has not been found!");
|
|
583
|
+
}
|
|
584
|
+
feature = new feature_1.default(foundFeature);
|
|
585
|
+
feature.geometry.coordinates = [
|
|
586
|
+
lng ? lng : feature.geometry.coordinates[0],
|
|
587
|
+
lat ? lat : feature.geometry.coordinates[1],
|
|
588
|
+
];
|
|
589
|
+
feature.properties = __assign(__assign({}, feature.properties), { title: title ? title : feature.properties.title, level: level ? level : feature.properties.level, amenity: icon ? id : feature.properties.amenity, images: icon ? [icon] : feature.properties.images, place_id: placeId ? placeId : feature.properties.place_id, floor_id: floorId ? floorId : feature.properties.floor_id });
|
|
590
|
+
if (!(icon && icon.length > 0)) return [3 /*break*/, 2];
|
|
591
|
+
return [4 /*yield*/, common_1.getImageFromBase64(icon)];
|
|
592
|
+
case 1:
|
|
593
|
+
decodedIcon = _a.sent();
|
|
594
|
+
this.map.addImage(id, decodedIcon);
|
|
595
|
+
_a.label = 2;
|
|
596
|
+
case 2:
|
|
597
|
+
dynamicIndex = this.state.dynamicFeatures.features.findIndex(function (x) { return x.id === feature.id || x.properties.id === feature.id; });
|
|
598
|
+
this.state.dynamicFeatures.features[dynamicIndex] = feature;
|
|
599
|
+
// this.state.allFeatures.features = [...this.state.features.features, ...this.state.dynamicFeatures.features]; // this is not probably updated with non dynamic feature update TODO
|
|
600
|
+
this.geojsonSource.update(feature);
|
|
601
|
+
// this.onSourceChange();
|
|
602
|
+
// this.routingSource.routing.setData(this.state.allFeatures);
|
|
603
|
+
// this.updateMapSource(this.routingSource);
|
|
604
|
+
this.onFeaturesChange();
|
|
605
|
+
this.onFeatureUpdateListener.next(feature);
|
|
606
|
+
return [2 /*return*/, feature];
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
Map.prototype.onDeleteFeature = function (id) {
|
|
612
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
613
|
+
var foundFeature, dynamicIndex;
|
|
614
|
+
return __generator(this, function (_a) {
|
|
615
|
+
foundFeature = this.state.allFeatures.features.find(function (f) { return f.id === id || f.properties.id === id; });
|
|
616
|
+
if (!foundFeature) {
|
|
617
|
+
console.error("Deleting feature failed: Feature with id '" + id + "' has not been found!");
|
|
618
|
+
throw new Error("Deleting feature failed: Feature with id '" + id + "' has not been found!");
|
|
619
|
+
}
|
|
620
|
+
dynamicIndex = this.state.dynamicFeatures.features.findIndex(function (x) { return x.id === id || x.properties.id === id; });
|
|
621
|
+
this.state.dynamicFeatures.features.splice(dynamicIndex, 1);
|
|
622
|
+
// this.state.allFeatures.features = [...this.state.features.features, ...this.state.dynamicFeatures.features]; // this is not probably updated with non dynamic feature delete TODO
|
|
623
|
+
this.geojsonSource.delete(id);
|
|
624
|
+
// this.onSourceChange();
|
|
625
|
+
// this.routingSource.routing.setData(this.state.allFeatures);
|
|
626
|
+
// this.updateMapSource(this.routingSource);
|
|
627
|
+
this.onFeaturesChange();
|
|
628
|
+
this.onFeatureDeleteListener.next(foundFeature);
|
|
629
|
+
return [2 /*return*/];
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
Map.prototype.onFeaturesChange = function () {
|
|
634
|
+
this.state.allFeatures.features = __spreadArray(__spreadArray([], this.state.features.features), this.state.dynamicFeatures.features);
|
|
635
|
+
this.onSourceChange();
|
|
636
|
+
this.routingSource.routing.setData(this.state.allFeatures);
|
|
637
|
+
this.updateMapSource(this.routingSource);
|
|
638
|
+
if (this.defaultOptions.enableTBTNavigation) {
|
|
639
|
+
this.routeFactory = new TBTNav.RouteFactory(JSON.stringify(this.state.allFeatures.features), 'en');
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
Map.prototype.onSetAmenityFilter = function (amenityId, category) {
|
|
643
|
+
if (category) {
|
|
644
|
+
this.amenityCategories[category].active = true;
|
|
645
|
+
this.amenityCategories[category].activeId = amenityId;
|
|
646
|
+
var amenities_1 = [];
|
|
647
|
+
var _loop_1 = function (key) {
|
|
648
|
+
if (this_1.amenityCategories.hasOwnProperty(key)) {
|
|
649
|
+
var cat_1 = this_1.amenityCategories[key];
|
|
650
|
+
if (cat_1.active) {
|
|
651
|
+
amenities_1 = amenities_1.concat(cat_1.amenities.filter(function (i) { return i !== cat_1.activeId; }));
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
var this_1 = this;
|
|
656
|
+
for (var key in this.amenityCategories) {
|
|
657
|
+
_loop_1(key);
|
|
658
|
+
}
|
|
659
|
+
this.amenityFilters = this.amenityIds.filter(function (el) { return !amenities_1.includes(el); });
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
if (this.amenityFilters.findIndex(function (i) { return i === amenityId; }) === -1) {
|
|
663
|
+
this.amenityFilters.push(amenityId);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
this.filteredAmenities = this.amenityFilters;
|
|
667
|
+
this.filterOutFeatures();
|
|
668
|
+
};
|
|
669
|
+
Map.prototype.onRemoveAmenityFilter = function (amenityId, category) {
|
|
670
|
+
if (category &&
|
|
671
|
+
this.amenityCategories[category].active &&
|
|
672
|
+
this.amenityCategories[category].activeId === amenityId) {
|
|
673
|
+
var amenities = this.amenityCategories[category].amenities.filter(function (i) { return i !== amenityId; });
|
|
674
|
+
this.amenityFilters = this.amenityFilters.concat(amenities);
|
|
675
|
+
this.amenityCategories[category].active = false;
|
|
676
|
+
}
|
|
677
|
+
else if (!category) {
|
|
678
|
+
this.amenityFilters = this.amenityFilters.filter(function (i) { return i !== amenityId; });
|
|
679
|
+
}
|
|
680
|
+
this.filteredAmenities = this.amenityFilters.length > 0 ? this.amenityFilters : this.amenityIds;
|
|
681
|
+
this.filterOutFeatures();
|
|
682
|
+
};
|
|
683
|
+
Map.prototype.onResetAmenityFilters = function () {
|
|
684
|
+
this.amenityFilters = [];
|
|
685
|
+
for (var key in this.amenityCategories) {
|
|
686
|
+
if (this.amenityCategories.hasOwnProperty(key)) {
|
|
687
|
+
this.amenityCategories[key].active = false;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
this.filteredAmenities = this.amenityIds;
|
|
691
|
+
this.filterOutFeatures();
|
|
692
|
+
};
|
|
693
|
+
Map.prototype.filterOutFeatures = function () {
|
|
694
|
+
var _this = this;
|
|
695
|
+
// proximiio-pois-icons, proximiio-pois-labels
|
|
696
|
+
var layers = ['proximiio-pois-icons', 'proximiio-pois-labels'];
|
|
697
|
+
if (this.defaultOptions.initPolygons) {
|
|
698
|
+
layers.push('poi-custom-icons', 'shop-labels');
|
|
699
|
+
}
|
|
700
|
+
layers.forEach(function (layer) {
|
|
701
|
+
if (_this.map.getLayer(layer)) {
|
|
702
|
+
setTimeout(function () {
|
|
703
|
+
var l = _this.map.getLayer(layer);
|
|
704
|
+
var filters = __spreadArray([], l.filter);
|
|
705
|
+
var amenityFilter = filters.findIndex(function (f) { return f[1][1] === 'amenity'; });
|
|
706
|
+
if (amenityFilter !== -1) {
|
|
707
|
+
filters[amenityFilter] = [
|
|
708
|
+
'match',
|
|
709
|
+
['get', 'amenity'],
|
|
710
|
+
_this.filteredAmenities ? _this.filteredAmenities : ['undefined'],
|
|
711
|
+
true,
|
|
712
|
+
false,
|
|
713
|
+
];
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
filters.push([
|
|
717
|
+
'match',
|
|
718
|
+
['get', 'amenity'],
|
|
719
|
+
_this.filteredAmenities ? _this.filteredAmenities : ['undefined'],
|
|
720
|
+
true,
|
|
721
|
+
false,
|
|
722
|
+
]);
|
|
723
|
+
}
|
|
724
|
+
_this.state.style.getLayer(layer).filter = filters;
|
|
725
|
+
_this.map.setFilter(layer, filters);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
this.state.style.notify('filter-change');
|
|
730
|
+
};
|
|
731
|
+
Map.prototype.onSetPerson = function (lat, lng, level, id) {
|
|
732
|
+
var person = new person_1.default({ lat: lat, lng: lng, level: level, id: id });
|
|
733
|
+
this.state = __assign(__assign({}, this.state), { persons: [person] });
|
|
734
|
+
this.initPersonsMap();
|
|
735
|
+
};
|
|
736
|
+
Map.prototype.onAddPerson = function (lat, lng, level, id) {
|
|
737
|
+
var person = new person_1.default({ lat: lat, lng: lng, level: level, id: id });
|
|
738
|
+
this.state.persons = __spreadArray(__spreadArray([], this.state.persons), [person]);
|
|
739
|
+
this.initPersonsMap();
|
|
740
|
+
};
|
|
741
|
+
Map.prototype.onUpdatePerson = function (person, lat, lng, level) {
|
|
742
|
+
person.updatePosition({ lat: lat, lng: lng, level: level });
|
|
743
|
+
this.initPersonsMap();
|
|
744
|
+
};
|
|
745
|
+
Map.prototype.initPersonsMap = function () {
|
|
746
|
+
var map = this.map;
|
|
747
|
+
if (!map.getLayer('persons-layer')) {
|
|
748
|
+
this.state.style.addLayer({
|
|
749
|
+
id: 'persons-layer',
|
|
750
|
+
type: 'symbol',
|
|
751
|
+
source: 'persons-source',
|
|
752
|
+
layout: {
|
|
753
|
+
'icon-image': 'person',
|
|
754
|
+
'icon-size': ['interpolate', ['exponential', 0.3], ['zoom'], 17, 0.1, 22, 0.3],
|
|
755
|
+
},
|
|
756
|
+
filter: ['all', ['==', ['to-number', ['get', 'level']], this.state.floor.level]],
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
if (!map.getSource('persons-source')) {
|
|
760
|
+
this.state.style.addSource('persons-source', {
|
|
761
|
+
type: 'geojson',
|
|
762
|
+
data: {
|
|
763
|
+
type: 'FeatureCollection',
|
|
764
|
+
features: [],
|
|
765
|
+
},
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
var personsCollection = this.state.persons.map(function (person) {
|
|
769
|
+
return turf.point([person.lat, person.lng], {
|
|
770
|
+
level: person.level,
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
this.state.style.sources['persons-source'].data = {
|
|
774
|
+
type: 'FeatureCollection',
|
|
775
|
+
features: personsCollection,
|
|
776
|
+
};
|
|
777
|
+
this.map.setStyle(this.state.style);
|
|
778
|
+
this.onPersonUpdateListener.next(this.state.persons);
|
|
779
|
+
};
|
|
780
|
+
Map.prototype.prepareStyle = function (style) {
|
|
781
|
+
style.setSource('main', this.geojsonSource);
|
|
782
|
+
style.setSource('synthetic', this.syntheticSource);
|
|
783
|
+
style.setSource('route', this.routingSource);
|
|
784
|
+
style.setSource('clusters', this.clusterSource);
|
|
785
|
+
style.setLevel(0);
|
|
786
|
+
};
|
|
787
|
+
Map.prototype.onRouteChange = function (event) {
|
|
788
|
+
var _this = this;
|
|
789
|
+
if (event === 'loading-start') {
|
|
790
|
+
this.state = __assign(__assign({}, this.state), { loadingRoute: true });
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
if (event === 'loading-finished') {
|
|
794
|
+
if (this.routingSource.route) {
|
|
795
|
+
var routeStart = this.routingSource.lines.find(function (l) { var _a; return +l.properties.level === ((_a = _this.routingSource.start) === null || _a === void 0 ? void 0 : _a.properties.level); });
|
|
796
|
+
var textNavigation = this.routeFactory.generateRoute(JSON.stringify(this.routingSource.points), JSON.stringify(this.endPoint));
|
|
797
|
+
this.centerOnRoute(routeStart);
|
|
798
|
+
this.state = __assign(__assign({}, this.state), { loadingRoute: false, textNavigation: textNavigation });
|
|
799
|
+
this.onRouteFoundListener.next({
|
|
800
|
+
route: this.routingSource.route,
|
|
801
|
+
TBTNav: this.defaultOptions.enableTBTNavigation ? textNavigation : null,
|
|
802
|
+
start: this.startPoint,
|
|
803
|
+
end: this.endPoint,
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (event === 'route-undefined') {
|
|
809
|
+
console.log('route not found');
|
|
810
|
+
this.state = __assign(__assign({}, this.state), { loadingRoute: false });
|
|
811
|
+
this.onRouteFailedListener.next('route not found');
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
var style = this.state.style;
|
|
815
|
+
style.setSource('route', this.routingSource);
|
|
816
|
+
this.state = __assign(__assign({}, this.state), { style: style });
|
|
817
|
+
this.updateMapSource(this.routingSource);
|
|
818
|
+
};
|
|
819
|
+
Map.prototype.onSourceChange = function () {
|
|
820
|
+
this.state = __assign(__assign({}, this.state), { style: this.state.style });
|
|
821
|
+
this.updateMapSource(this.geojsonSource);
|
|
822
|
+
// this.routingSource.routing.setData(this.geojsonSource.collection)
|
|
823
|
+
this.updateCluster();
|
|
824
|
+
};
|
|
825
|
+
Map.prototype.onSyntheticChange = function () {
|
|
826
|
+
this.state.style.setSource('synthetic', this.syntheticSource);
|
|
827
|
+
this.updateMapSource(this.syntheticSource);
|
|
828
|
+
};
|
|
829
|
+
Map.prototype.updateMapSource = function (source) {
|
|
830
|
+
var map = this.map;
|
|
831
|
+
if (map && map.getSource(source.id)) {
|
|
832
|
+
var mapSource = map.getSource(source.id);
|
|
833
|
+
if (mapSource) {
|
|
834
|
+
mapSource.setData(source.data);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
Map.prototype.onStyleSelect = function (style) {
|
|
839
|
+
var map = this.map;
|
|
840
|
+
if (map) {
|
|
841
|
+
this.prepareStyle(style);
|
|
842
|
+
map.setStyle(style.json);
|
|
843
|
+
}
|
|
844
|
+
this.state = __assign(__assign({}, this.state), { style: style });
|
|
845
|
+
};
|
|
846
|
+
Map.prototype.onStyleChange = function (event, data) {
|
|
847
|
+
var map = this.map;
|
|
848
|
+
if (map) {
|
|
849
|
+
if (event === 'overlay-toggled') {
|
|
850
|
+
var overlay = this.state.style.overlay ? 'visible' : 'none';
|
|
851
|
+
map.setLayoutProperty('main-polygon-fill', 'visibility', overlay);
|
|
852
|
+
map.setLayoutProperty('main-polygon-outline', 'visibility', overlay);
|
|
853
|
+
}
|
|
854
|
+
if (event === 'segments-toggled') {
|
|
855
|
+
var segments = this.state.style.segments ? 'visible' : 'none';
|
|
856
|
+
map.setLayoutProperty('main-segment-fill', 'visibility', segments);
|
|
857
|
+
map.setLayoutProperty('main-segment-outline', 'visibility', segments);
|
|
858
|
+
}
|
|
859
|
+
if (event === 'routable-toggled') {
|
|
860
|
+
var routables = this.state.style.segments ? 'visible' : 'none';
|
|
861
|
+
map.setLayoutProperty('main-routable-fill', 'visibility', routables);
|
|
862
|
+
map.setLayoutProperty('main-routable-outline', 'visibility', routables);
|
|
863
|
+
}
|
|
864
|
+
if (event === 'cluster-toggled') {
|
|
865
|
+
var clusters = this.state.style.cluster ? 'visible' : 'none';
|
|
866
|
+
map.setLayoutProperty('clusters-circle', 'visibility', clusters);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (event === 'layer-update' && data) {
|
|
870
|
+
var layer_1 = data.layer, changes = data.changes;
|
|
871
|
+
var layoutChanges = changes.filter(function (diff) { return diff.kind === 'E' && diff.path[0] === 'layout'; });
|
|
872
|
+
var paintChanges = changes.filter(function (diff) { return diff.kind === 'E' && diff.path[0] === 'paint'; });
|
|
873
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
874
|
+
var map_1 = this.map;
|
|
875
|
+
if (map_1) {
|
|
876
|
+
layoutChanges.forEach(function (change) {
|
|
877
|
+
if (change.kind === 'E') {
|
|
878
|
+
map_1.setLayoutProperty(layer_1.id, change.path[1], change.rhs);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
paintChanges.forEach(function (change) {
|
|
882
|
+
if (change.kind === 'E') {
|
|
883
|
+
map_1.setPaintProperty(layer_1.id, change.path[1], change.rhs);
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (event === 'filter-change') {
|
|
889
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
890
|
+
var map_2 = this.map;
|
|
891
|
+
this.state.style.getLayers('main').forEach(function (layer) {
|
|
892
|
+
if (map_2.getLayer(layer.id)) {
|
|
893
|
+
map_2.removeLayer(layer.id);
|
|
894
|
+
}
|
|
895
|
+
// @ts-ignore
|
|
896
|
+
map_2.addLayer(layer);
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
// @ts-ignore
|
|
900
|
+
this.map.setStyle(this.state.style);
|
|
901
|
+
this.state = __assign(__assign({}, this.state), { style: this.state.style });
|
|
902
|
+
};
|
|
903
|
+
Map.prototype.onRasterToggle = function (value) {
|
|
904
|
+
this.imageSourceManager.enabled = value;
|
|
905
|
+
var map = this.map;
|
|
906
|
+
if (map) {
|
|
907
|
+
this.imageSourceManager.setLevel(map, this.state.floor.level);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
Map.prototype.updateCluster = function () {
|
|
911
|
+
var _this = this;
|
|
912
|
+
var map = this.map;
|
|
913
|
+
if (map) {
|
|
914
|
+
var data = {
|
|
915
|
+
type: 'FeatureCollection',
|
|
916
|
+
features: this.geojsonSource.data.features
|
|
917
|
+
.filter(function (f) { return f.isPoint && f.hasLevel(_this.state.floor.level); })
|
|
918
|
+
.map(function (f) { return f.json; }),
|
|
919
|
+
};
|
|
920
|
+
var source = map.getSource('clusters');
|
|
921
|
+
if (source) {
|
|
922
|
+
source.setData(data);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
Map.prototype.onPlaceSelect = function (place, zoomIntoPlace, floorLevel) {
|
|
927
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
928
|
+
var floors, state, defaultFloor, map;
|
|
929
|
+
return __generator(this, function (_a) {
|
|
930
|
+
switch (_a.label) {
|
|
931
|
+
case 0:
|
|
932
|
+
this.state = __assign(__assign({}, this.state), { place: place });
|
|
933
|
+
return [4 /*yield*/, floors_1.getPlaceFloors(place.id)];
|
|
934
|
+
case 1:
|
|
935
|
+
floors = _a.sent();
|
|
936
|
+
state = { floors: floors.sort(function (a, b) { return a.level - b.level; }) };
|
|
937
|
+
if (floors.length > 0) {
|
|
938
|
+
defaultFloor = floorLevel
|
|
939
|
+
? floors.find(function (floor) { return floor.level === floorLevel; })
|
|
940
|
+
: floors.find(function (floor) { return floor.level === 0; });
|
|
941
|
+
if (defaultFloor) {
|
|
942
|
+
state.floor = defaultFloor;
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
state.floor = floors[0];
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
this.state = __assign(__assign({}, this.state), state);
|
|
949
|
+
map = this.map;
|
|
950
|
+
if (map && zoomIntoPlace) {
|
|
951
|
+
map.flyTo({ center: [place.location.lng, place.location.lat] });
|
|
952
|
+
}
|
|
953
|
+
this.onPlaceSelectListener.next(place);
|
|
954
|
+
this.onFloorSelect(state.floor);
|
|
955
|
+
return [2 /*return*/];
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
};
|
|
960
|
+
Map.prototype.onFloorSelect = function (floor) {
|
|
961
|
+
var _this = this;
|
|
962
|
+
var map = this.map;
|
|
963
|
+
var route = this.routingSource.route && this.routingSource.route[floor.level] ? this.routingSource.route[floor.level] : null;
|
|
964
|
+
if (map) {
|
|
965
|
+
this.state.style.setLevel(floor.level);
|
|
966
|
+
map.setStyle(this.state.style);
|
|
967
|
+
setTimeout(function () {
|
|
968
|
+
__spreadArray(__spreadArray([], _this.state.style.getLayers('main')), _this.state.style.getLayers('route')).forEach(function (layer) {
|
|
969
|
+
if (map.getLayer(layer.id)) {
|
|
970
|
+
map.setFilter(layer.id, layer.filter);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
_this.imageSourceManager.setLevel(map, floor.level);
|
|
974
|
+
});
|
|
975
|
+
if (route) {
|
|
976
|
+
var bbox = turf.bbox(route.geometry);
|
|
977
|
+
// @ts-ignore;
|
|
978
|
+
map.fitBounds(bbox, { padding: 250, bearing: this.map.getBearing(), pitch: this.map.getPitch() });
|
|
979
|
+
}
|
|
980
|
+
if (this.defaultOptions.isKiosk && map.getLayer('my-location-layer')) {
|
|
981
|
+
var filter = ['all', ['==', ['to-number', ['get', 'level']], floor.level]];
|
|
982
|
+
map.setFilter('my-location-layer', filter);
|
|
983
|
+
this.state.style.getLayer('my-location-layer').filter = filter;
|
|
984
|
+
}
|
|
985
|
+
if (map.getLayer('persons-layer')) {
|
|
986
|
+
var filter = ['all', ['==', ['to-number', ['get', 'level']], floor.level]];
|
|
987
|
+
map.setFilter('persons-layer', filter);
|
|
988
|
+
this.state.style.getLayer('persons-layer').filter = filter;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
this.state = __assign(__assign({}, this.state), { floor: floor, style: this.state.style });
|
|
992
|
+
this.updateCluster();
|
|
993
|
+
this.onFloorSelectListener.next(floor);
|
|
994
|
+
};
|
|
995
|
+
Map.prototype.onRouteUpdate = function (start, finish) {
|
|
996
|
+
this.startPoint = start;
|
|
997
|
+
this.endPoint = finish;
|
|
998
|
+
try {
|
|
999
|
+
if (finish && this.defaultOptions.initPolygons) {
|
|
1000
|
+
this.handlePolygonSelection(finish);
|
|
1001
|
+
}
|
|
1002
|
+
this.routingSource.update(start, finish);
|
|
1003
|
+
}
|
|
1004
|
+
catch (e) {
|
|
1005
|
+
console.log('catched', e);
|
|
1006
|
+
}
|
|
1007
|
+
this.state = __assign(__assign({}, this.state), { style: this.state.style });
|
|
1008
|
+
};
|
|
1009
|
+
Map.prototype.onRouteCancel = function () {
|
|
1010
|
+
this.state = __assign(__assign({}, this.state), { textNavigation: null });
|
|
1011
|
+
if (this.defaultOptions.initPolygons) {
|
|
1012
|
+
this.handlePolygonSelection();
|
|
1013
|
+
}
|
|
1014
|
+
this.routingSource.cancel();
|
|
1015
|
+
this.onRouteCancelListener.next('route cancelled');
|
|
1016
|
+
};
|
|
1017
|
+
Map.prototype.centerOnPoi = function (poi) {
|
|
1018
|
+
if (this.state.floor.level !== parseInt(poi.properties.level, 0)) {
|
|
1019
|
+
var floor = this.state.floors.find(function (f) { return f.level === poi.properties.level; });
|
|
1020
|
+
if (floor)
|
|
1021
|
+
this.onFloorSelect(floor);
|
|
1022
|
+
}
|
|
1023
|
+
if (this.map) {
|
|
1024
|
+
this.map.flyTo({ center: poi.geometry.coordinates });
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
Map.prototype.centerOnRoute = function (route) {
|
|
1028
|
+
if (route && route.properties) {
|
|
1029
|
+
if (this.state.floor.level !== +route.properties.level) {
|
|
1030
|
+
var floor = this.state.floors.find(function (f) { return f.level === +route.properties.level; });
|
|
1031
|
+
if (floor)
|
|
1032
|
+
this.onFloorSelect(floor);
|
|
1033
|
+
}
|
|
1034
|
+
if (this.map) {
|
|
1035
|
+
var bbox = turf.bbox(route.geometry);
|
|
1036
|
+
// @ts-ignore
|
|
1037
|
+
this.map.fitBounds(bbox, { padding: 250, bearing: this.map.getBearing(), pitch: this.map.getPitch() });
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
Map.prototype.centerOnCoords = function (lat, lng, zoom) {
|
|
1042
|
+
if (this.map) {
|
|
1043
|
+
this.map.flyTo({ center: [lng, lat], zoom: zoom ? zoom : 18 });
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
Map.prototype.updateImages = function () {
|
|
1047
|
+
var _this = this;
|
|
1048
|
+
this.state.amenities
|
|
1049
|
+
.filter(function (a) { return a.icon; })
|
|
1050
|
+
.forEach(function (amenity) {
|
|
1051
|
+
_this.amenityIds.push(amenity.id);
|
|
1052
|
+
_this.map.loadImage(amenity.icon, function (error, image) {
|
|
1053
|
+
if (error)
|
|
1054
|
+
throw error;
|
|
1055
|
+
_this.map.addImage(amenity.id, image);
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
};
|
|
1059
|
+
Map.prototype.getUpcomingFloorNumber = function (way) {
|
|
1060
|
+
var _this = this;
|
|
1061
|
+
if (this.routingSource.lines && this.routingSource.route) {
|
|
1062
|
+
var currentRouteIndex = this.routingSource.lines.findIndex(function (route) { return +route.properties.level === _this.state.floor.level; });
|
|
1063
|
+
var currentRoute = this.routingSource.lines[currentRouteIndex];
|
|
1064
|
+
var nextRouteIndex = way === 'up' ? currentRouteIndex + 1 : currentRouteIndex - 1;
|
|
1065
|
+
var nextRoute = this.routingSource.lines[nextRouteIndex];
|
|
1066
|
+
// return currentRouteIndex !== -1 && nextRoute ? +nextRoute.properties.level : way === 'up' ? this.state.floor.level + 1 : this.state.floor.level - 1;
|
|
1067
|
+
return nextRoute ? +nextRoute.properties.level : this.state.floor.level;
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
/**
|
|
1071
|
+
* @memberof Map
|
|
1072
|
+
* @name getMapboxInstance
|
|
1073
|
+
* @returns returns mapbox instance
|
|
1074
|
+
* @example
|
|
1075
|
+
* const map = new Proximiio.Map();
|
|
1076
|
+
* map.getMapboxInstance();
|
|
1077
|
+
*/
|
|
1078
|
+
Map.prototype.getMapboxInstance = function () {
|
|
1079
|
+
return this.map;
|
|
1080
|
+
};
|
|
1081
|
+
/**
|
|
1082
|
+
* @memberof Map
|
|
1083
|
+
* @name getMapReadyListener
|
|
1084
|
+
* @returns returns map ready listener
|
|
1085
|
+
* @example
|
|
1086
|
+
* const map = new Proximiio.Map();
|
|
1087
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1088
|
+
* console.log('map ready', ready);
|
|
1089
|
+
* });
|
|
1090
|
+
*/
|
|
1091
|
+
Map.prototype.getMapReadyListener = function () {
|
|
1092
|
+
return this.onMapReadyListener.asObservable();
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* This method will set an active place, load floors etc. Have to be called after map is ready, see getMapReadyListener.
|
|
1096
|
+
* @memberof Map
|
|
1097
|
+
* @name setPlace
|
|
1098
|
+
* @param placeId {string} Id of the place to be set as active on map
|
|
1099
|
+
* @param zoomIntoPlace {boolean} should zoom into active place, optional
|
|
1100
|
+
* @param floorLevel {number} Level of the floor to be set as active on map, optional
|
|
1101
|
+
* @returns active place
|
|
1102
|
+
* @example
|
|
1103
|
+
* const map = new Proximiio.Map();
|
|
1104
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1105
|
+
* console.log('map ready', ready);
|
|
1106
|
+
* map.setPlace(myPlaceId);
|
|
1107
|
+
* });
|
|
1108
|
+
*/
|
|
1109
|
+
Map.prototype.setPlace = function (placeId, zoomIntoPlace, floorLevel) {
|
|
1110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1111
|
+
var place, shouldZoom;
|
|
1112
|
+
return __generator(this, function (_a) {
|
|
1113
|
+
switch (_a.label) {
|
|
1114
|
+
case 0: return [4 /*yield*/, places_1.getPlaceById(placeId)];
|
|
1115
|
+
case 1:
|
|
1116
|
+
place = _a.sent();
|
|
1117
|
+
shouldZoom = typeof zoomIntoPlace !== 'undefined' ? zoomIntoPlace : true;
|
|
1118
|
+
return [4 /*yield*/, this.onPlaceSelect(place, shouldZoom, floorLevel)];
|
|
1119
|
+
case 2:
|
|
1120
|
+
_a.sent();
|
|
1121
|
+
return [2 /*return*/, place];
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* @memberof Map
|
|
1128
|
+
* @name getPlaceSelectListener
|
|
1129
|
+
* @returns returns place select listener
|
|
1130
|
+
* @example
|
|
1131
|
+
* const map = new Proximiio.Map();
|
|
1132
|
+
* map.getPlaceSelectListener().subscribe(place => {
|
|
1133
|
+
* console.log('selected place', place);
|
|
1134
|
+
* });
|
|
1135
|
+
*/
|
|
1136
|
+
Map.prototype.getPlaceSelectListener = function () {
|
|
1137
|
+
return this.onPlaceSelectListener.asObservable();
|
|
1138
|
+
};
|
|
1139
|
+
/**
|
|
1140
|
+
* This method will set an active floor based on it's id. Have to be called after map is ready, see getMapReadyListener.
|
|
1141
|
+
* @memberof Map
|
|
1142
|
+
* @name setFloorById
|
|
1143
|
+
* @param floorId {string} Id of the floor to be set as active on map
|
|
1144
|
+
* @returns active floor
|
|
1145
|
+
* @example
|
|
1146
|
+
* const map = new Proximiio.Map();
|
|
1147
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1148
|
+
* console.log('map ready', ready);
|
|
1149
|
+
* map.setFloorById(myFloorId);
|
|
1150
|
+
* });
|
|
1151
|
+
*/
|
|
1152
|
+
Map.prototype.setFloorById = function (floorId) {
|
|
1153
|
+
var floor = this.state.floors.filter(function (f) { return f.id === floorId; })
|
|
1154
|
+
? this.state.floors.filter(function (f) { return f.id === floorId; })[0]
|
|
1155
|
+
: this.state.floor;
|
|
1156
|
+
if (floor) {
|
|
1157
|
+
this.onFloorSelect(new floor_1.FloorModel(floor));
|
|
1158
|
+
}
|
|
1159
|
+
return floor;
|
|
1160
|
+
};
|
|
1161
|
+
/**
|
|
1162
|
+
* This method will set an active floor based on it's level. Have to be called after map is ready, see getMapReadyListener.
|
|
1163
|
+
* @memberof Map
|
|
1164
|
+
* @name setFloorByLevel
|
|
1165
|
+
* @param level {number} Level of the floor to be set as active on map
|
|
1166
|
+
* @returns active floor
|
|
1167
|
+
* @example
|
|
1168
|
+
* const map = new Proximiio.Map();
|
|
1169
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1170
|
+
* console.log('map ready', ready);
|
|
1171
|
+
* map.setFloorByLevel(0);
|
|
1172
|
+
* });
|
|
1173
|
+
*/
|
|
1174
|
+
Map.prototype.setFloorByLevel = function (level) {
|
|
1175
|
+
var floor = this.state.floors.filter(function (f) { return f.level === level; })
|
|
1176
|
+
? this.state.floors.filter(function (f) { return f.level === level; })[0]
|
|
1177
|
+
: this.state.floor;
|
|
1178
|
+
if (floor) {
|
|
1179
|
+
this.onFloorSelect(new floor_1.FloorModel(floor));
|
|
1180
|
+
}
|
|
1181
|
+
return floor;
|
|
1182
|
+
};
|
|
1183
|
+
/**
|
|
1184
|
+
* This method will set an active floor based on the way of the next floor, e.g if we wanna go up or down. Have to be called after map is ready, see getMapReadyListener.
|
|
1185
|
+
* @memberof Map
|
|
1186
|
+
* @name setFloorByWay
|
|
1187
|
+
* @param way {'up' | 'down'} Way of the next floor to be set as active on map
|
|
1188
|
+
* @returns active floor
|
|
1189
|
+
* @example
|
|
1190
|
+
* const map = new Proximiio.Map();
|
|
1191
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1192
|
+
* console.log('map ready', ready);
|
|
1193
|
+
* map.setFloorByWay('up');
|
|
1194
|
+
* });
|
|
1195
|
+
*/
|
|
1196
|
+
Map.prototype.setFloorByWay = function (way) {
|
|
1197
|
+
var floor;
|
|
1198
|
+
var nextLevel = way === 'up' ? this.state.floor.level + 1 : this.state.floor.level - 1;
|
|
1199
|
+
if (this.routingSource.route) {
|
|
1200
|
+
nextLevel = this.getUpcomingFloorNumber(way);
|
|
1201
|
+
}
|
|
1202
|
+
floor = this.state.floors.filter(function (f) { return f.level === nextLevel; })
|
|
1203
|
+
? this.state.floors.filter(function (f) { return f.level === nextLevel; })[0]
|
|
1204
|
+
: this.state.floor;
|
|
1205
|
+
if (floor) {
|
|
1206
|
+
this.onFloorSelect(new floor_1.FloorModel(floor));
|
|
1207
|
+
}
|
|
1208
|
+
return floor;
|
|
1209
|
+
};
|
|
1210
|
+
/**
|
|
1211
|
+
* @memberof Map
|
|
1212
|
+
* @name getFloorSelectListener
|
|
1213
|
+
* @returns returns floor select listener
|
|
1214
|
+
* @example
|
|
1215
|
+
* const map = new Proximiio.Map();
|
|
1216
|
+
* map.getFloorSelectListener().subscribe(floor => {
|
|
1217
|
+
* console.log('selected floor', floor);
|
|
1218
|
+
* });
|
|
1219
|
+
*/
|
|
1220
|
+
Map.prototype.getFloorSelectListener = function () {
|
|
1221
|
+
return this.onFloorSelectListener.asObservable();
|
|
1222
|
+
};
|
|
1223
|
+
/**
|
|
1224
|
+
* This method will generate route based on selected features by their ids
|
|
1225
|
+
* @memberof Map
|
|
1226
|
+
* @name findRouteByIds
|
|
1227
|
+
* @param idTo {string} finish feature id
|
|
1228
|
+
* @param idFrom {string} start feature id, optional for kiosk
|
|
1229
|
+
* @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
|
|
1230
|
+
* @example
|
|
1231
|
+
* const map = new Proximiio.Map();
|
|
1232
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1233
|
+
* console.log('map ready', ready);
|
|
1234
|
+
* map.findRouteByIds('finishId, 'startId');
|
|
1235
|
+
* });
|
|
1236
|
+
*/
|
|
1237
|
+
Map.prototype.findRouteByIds = function (idTo, idFrom, accessibleRoute) {
|
|
1238
|
+
var fromFeature = this.defaultOptions.isKiosk
|
|
1239
|
+
? this.startPoint
|
|
1240
|
+
: this.state.allFeatures.features.find(function (f) { return f.id === idFrom || f.properties.id === idFrom; });
|
|
1241
|
+
var toFeature = this.state.allFeatures.features.find(function (f) { return f.id === idTo || f.properties.id === idTo; });
|
|
1242
|
+
this.routingSource.toggleAccessible(accessibleRoute);
|
|
1243
|
+
this.onRouteUpdate(fromFeature, toFeature);
|
|
1244
|
+
};
|
|
1245
|
+
/**
|
|
1246
|
+
* This method will generate route based on selected features by their titles
|
|
1247
|
+
* @memberof Map
|
|
1248
|
+
* @name findRouteByTitle
|
|
1249
|
+
* @param titleTo {string} finish feature title
|
|
1250
|
+
* @param titleFrom {string} start feature title, optional for kiosk
|
|
1251
|
+
* @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
|
|
1252
|
+
* @example
|
|
1253
|
+
* const map = new Proximiio.Map();
|
|
1254
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1255
|
+
* console.log('map ready', ready);
|
|
1256
|
+
* map.findRouteByTitle('myFeatureTitle', 'anotherFeatureTitle');
|
|
1257
|
+
* });
|
|
1258
|
+
*/
|
|
1259
|
+
Map.prototype.findRouteByTitle = function (titleTo, titleFrom, accessibleRoute) {
|
|
1260
|
+
var fromFeature = this.defaultOptions.isKiosk
|
|
1261
|
+
? this.startPoint
|
|
1262
|
+
: this.state.allFeatures.features.find(function (f) { return f.properties.title === titleFrom; });
|
|
1263
|
+
var toFeature = this.state.allFeatures.features.find(function (f) { return f.properties.title === titleTo; });
|
|
1264
|
+
this.routingSource.toggleAccessible(accessibleRoute);
|
|
1265
|
+
this.onRouteUpdate(this.defaultOptions.isKiosk ? this.startPoint : fromFeature, toFeature);
|
|
1266
|
+
};
|
|
1267
|
+
/**
|
|
1268
|
+
* This method will generate route based on selected features by their titles
|
|
1269
|
+
* @memberof Map
|
|
1270
|
+
* @name findRouteByCoords
|
|
1271
|
+
* @param latTo {number} finish latitude coordinate
|
|
1272
|
+
* @param lngTo {number} finish longitude coordinate
|
|
1273
|
+
* @param levelTo {number} finish level
|
|
1274
|
+
* @param latFrom {number} start latitude coordinate, optional for kiosk
|
|
1275
|
+
* @param lngFrom {number} start longitude coordinate, optional for kiosk
|
|
1276
|
+
* @param levelFrom {number} start level, optional for kiosk
|
|
1277
|
+
* @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
|
|
1278
|
+
* @example
|
|
1279
|
+
* const map = new Proximiio.Map();
|
|
1280
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1281
|
+
* console.log('map ready', ready);
|
|
1282
|
+
* map.findRouteByCoords(48.606703739771774, 17.833092384506614, 0, 48.60684545080579, 17.833450676669543, 0);
|
|
1283
|
+
* });
|
|
1284
|
+
*/
|
|
1285
|
+
Map.prototype.findRouteByCoords = function (latTo, lngTo, levelTo, latFrom, lngFrom, levelFrom, accessibleRoute) {
|
|
1286
|
+
var fromFeature = this.defaultOptions.isKiosk
|
|
1287
|
+
? this.startPoint
|
|
1288
|
+
: turf.feature({ type: 'Point', coordinates: [lngFrom, latFrom] }, { level: levelFrom });
|
|
1289
|
+
var toFeature = turf.feature({ type: 'Point', coordinates: [lngTo, latTo] }, { level: levelTo });
|
|
1290
|
+
this.routingSource.toggleAccessible(accessibleRoute);
|
|
1291
|
+
this.onRouteUpdate(this.defaultOptions.isKiosk ? this.startPoint : fromFeature, toFeature);
|
|
1292
|
+
};
|
|
1293
|
+
/**
|
|
1294
|
+
* This method will cancel generated route
|
|
1295
|
+
* @memberof Map
|
|
1296
|
+
* @name cancelRoute
|
|
1297
|
+
* @example
|
|
1298
|
+
* const map = new Proximiio.Map();
|
|
1299
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1300
|
+
* console.log('map ready', ready);
|
|
1301
|
+
* map.cancelRoute();
|
|
1302
|
+
* });
|
|
1303
|
+
*/
|
|
1304
|
+
Map.prototype.cancelRoute = function () {
|
|
1305
|
+
this.onRouteCancel();
|
|
1306
|
+
};
|
|
1307
|
+
/**
|
|
1308
|
+
* This method will return turn by turn text navigation object.
|
|
1309
|
+
* @memberof Map
|
|
1310
|
+
* @name getTBTNav
|
|
1311
|
+
* @return turn by turn text navigation object
|
|
1312
|
+
* @example
|
|
1313
|
+
* const map = new Proximiio.Map();
|
|
1314
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1315
|
+
* console.log('map ready', ready);
|
|
1316
|
+
* const TBTNav = map.getTBTNav();
|
|
1317
|
+
* });
|
|
1318
|
+
*/
|
|
1319
|
+
Map.prototype.getTBTNav = function () {
|
|
1320
|
+
return this.state.textNavigation;
|
|
1321
|
+
};
|
|
1322
|
+
/**
|
|
1323
|
+
* @memberof Map
|
|
1324
|
+
* @name getRouteFoundListener
|
|
1325
|
+
* @returns returns route found listener
|
|
1326
|
+
* @example
|
|
1327
|
+
* const map = new Proximiio.Map();
|
|
1328
|
+
* map.getRouteFoundListener().subscribe(res => {
|
|
1329
|
+
* console.log('route found successfully', res.route);
|
|
1330
|
+
* console.log('turn by turn text navigation output', res.TBTNav);
|
|
1331
|
+
* });
|
|
1332
|
+
*/
|
|
1333
|
+
Map.prototype.getRouteFoundListener = function () {
|
|
1334
|
+
return this.onRouteFoundListener.asObservable();
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* @memberof Map
|
|
1338
|
+
* @name getRouteFailedListener
|
|
1339
|
+
* @returns returns route fail listener
|
|
1340
|
+
* @example
|
|
1341
|
+
* const map = new Proximiio.Map();
|
|
1342
|
+
* map.getRouteFailedListener().subscribe(() => {
|
|
1343
|
+
* console.log('route not found');
|
|
1344
|
+
* });
|
|
1345
|
+
*/
|
|
1346
|
+
Map.prototype.getRouteFailedListener = function () {
|
|
1347
|
+
return this.onRouteFailedListener.asObservable();
|
|
1348
|
+
};
|
|
1349
|
+
/**
|
|
1350
|
+
* @memberof Map
|
|
1351
|
+
* @name getRouteCancelListener
|
|
1352
|
+
* @returns returns route cancel listener
|
|
1353
|
+
* @example
|
|
1354
|
+
* const map = new Proximiio.Map();
|
|
1355
|
+
* map.getRouteCancelListener().subscribe(() => {
|
|
1356
|
+
* console.log('route cancelled);
|
|
1357
|
+
* });
|
|
1358
|
+
*/
|
|
1359
|
+
Map.prototype.getRouteCancelListener = function () {
|
|
1360
|
+
return this.onRouteCancelListener.asObservable();
|
|
1361
|
+
};
|
|
1362
|
+
/**
|
|
1363
|
+
* This method will center the map to generated route bounds.
|
|
1364
|
+
* @memberof Map
|
|
1365
|
+
* @name centerToRoute
|
|
1366
|
+
* @return error {string} in case there is no route or {Feature} otherwise
|
|
1367
|
+
* @example
|
|
1368
|
+
* const map = new Proximiio.Map();
|
|
1369
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1370
|
+
* console.log('map ready', ready);
|
|
1371
|
+
* map.centerToRoute();
|
|
1372
|
+
* });
|
|
1373
|
+
*/
|
|
1374
|
+
Map.prototype.centerToRoute = function () {
|
|
1375
|
+
var _a, _b;
|
|
1376
|
+
if (this.routingSource &&
|
|
1377
|
+
this.routingSource.route &&
|
|
1378
|
+
this.routingSource.route[(_a = this.routingSource.start) === null || _a === void 0 ? void 0 : _a.properties.level]) {
|
|
1379
|
+
var routeStart = this.routingSource.route[(_b = this.routingSource.start) === null || _b === void 0 ? void 0 : _b.properties.level];
|
|
1380
|
+
this.centerOnRoute(routeStart);
|
|
1381
|
+
return routeStart;
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
throw new Error("Route not found");
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
/**
|
|
1388
|
+
* This method will center the map to feature coordinates.
|
|
1389
|
+
* @memberof Map
|
|
1390
|
+
* @name centerToFeature
|
|
1391
|
+
* @param featureId {string} feature id
|
|
1392
|
+
* @return error {string} in case there is no feature or {Feature} otherwise
|
|
1393
|
+
* @example
|
|
1394
|
+
* const map = new Proximiio.Map();
|
|
1395
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1396
|
+
* console.log('map ready', ready);
|
|
1397
|
+
* map.centerToFeature('featureId');
|
|
1398
|
+
* });
|
|
1399
|
+
*/
|
|
1400
|
+
Map.prototype.centerToFeature = function (featureId) {
|
|
1401
|
+
var feature = this.state.allFeatures.features.find(function (f) { return f.id === featureId || f.properties.id === featureId; });
|
|
1402
|
+
if (feature) {
|
|
1403
|
+
this.centerOnPoi(feature);
|
|
1404
|
+
return feature;
|
|
1405
|
+
}
|
|
1406
|
+
else {
|
|
1407
|
+
throw new Error("Feature not found");
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
/**
|
|
1411
|
+
* This method will center the map to provided coordinates.
|
|
1412
|
+
* @memberof Map
|
|
1413
|
+
* @name centerToCoordinates
|
|
1414
|
+
* @param lat {number} latitude coordinate, required
|
|
1415
|
+
* @param lng {number} longitude coordinate, required
|
|
1416
|
+
* @param zoom {number} zoom level, optional, 18 as default
|
|
1417
|
+
* @example
|
|
1418
|
+
* const map = new Proximiio.Map();
|
|
1419
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1420
|
+
* console.log('map ready', ready);
|
|
1421
|
+
* map.centerToCoordinates(48.60678469647394, 17.833135351538658, 20);
|
|
1422
|
+
* });
|
|
1423
|
+
*/
|
|
1424
|
+
Map.prototype.centerToCoordinates = function (lat, lng, zoom) {
|
|
1425
|
+
this.centerOnCoords(lat, lng, zoom);
|
|
1426
|
+
};
|
|
1427
|
+
/**
|
|
1428
|
+
* Add new feature to map.
|
|
1429
|
+
* @memberof Map
|
|
1430
|
+
* @name addCustomFeature
|
|
1431
|
+
* @param title {string} feature title, required
|
|
1432
|
+
* @param level {number} feature floor level, required
|
|
1433
|
+
* @param lat {number} feature latitude coordinate, required
|
|
1434
|
+
* @param lng {number} feature longitude coordinate, required
|
|
1435
|
+
* @param icon {string} feature icon image in base64 format, optional
|
|
1436
|
+
* @param id {string} feature id, optional, will be autogenerated if not defined
|
|
1437
|
+
* @param placeId {string} feature place_id, optional
|
|
1438
|
+
* @param floorId {string} feature floor_id, optional
|
|
1439
|
+
* @return <Promise>{Feature} newly added feature
|
|
1440
|
+
* @example
|
|
1441
|
+
* const map = new Proximiio.Map();
|
|
1442
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1443
|
+
* console.log('map ready', ready);
|
|
1444
|
+
* const myFeature = map.addCustomFeature('myPOI', 0, 48.606703739771774, 17.833092384506614);
|
|
1445
|
+
* });
|
|
1446
|
+
*/
|
|
1447
|
+
Map.prototype.addCustomFeature = function (title, level, lat, lng, icon, id, placeId, floorId) {
|
|
1448
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1449
|
+
return __generator(this, function (_a) {
|
|
1450
|
+
switch (_a.label) {
|
|
1451
|
+
case 0: return [4 /*yield*/, this.onAddNewFeature(title, +level, +lat, +lng, icon, id, placeId, floorId)];
|
|
1452
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
});
|
|
1456
|
+
};
|
|
1457
|
+
/**
|
|
1458
|
+
* Update existing map feature.
|
|
1459
|
+
* @memberof Map
|
|
1460
|
+
* @name updateFeature
|
|
1461
|
+
* @param id {string} feature id
|
|
1462
|
+
* @param title {string} feature title, optional
|
|
1463
|
+
* @param level {number} feature floor level, optional
|
|
1464
|
+
* @param lat {number} feature latitude coordinate, optional
|
|
1465
|
+
* @param lng {number} feature longitude coordinate, optional
|
|
1466
|
+
* @param icon {string} feature icon image in base64 format, optional
|
|
1467
|
+
* @param placeId {string} feature place_id, optional
|
|
1468
|
+
* @param floorId {string} feature floor_id, optional
|
|
1469
|
+
* @return <Promise>{Feature} newly added feature
|
|
1470
|
+
* @example
|
|
1471
|
+
* const map = new Proximiio.Map();
|
|
1472
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1473
|
+
* console.log('map ready', ready);
|
|
1474
|
+
* const myFeature = map.updateFeature('poiId', 'myPOI', 0, 48.606703739771774, 17.833092384506614);
|
|
1475
|
+
* });
|
|
1476
|
+
*/
|
|
1477
|
+
Map.prototype.updateFeature = function (id, title, level, lat, lng, icon, placeId, floorId) {
|
|
1478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1479
|
+
return __generator(this, function (_a) {
|
|
1480
|
+
switch (_a.label) {
|
|
1481
|
+
case 0: return [4 /*yield*/, this.onUpdateFeature(id, title, level, lat, lng, icon, placeId, floorId)];
|
|
1482
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
};
|
|
1487
|
+
/**
|
|
1488
|
+
* Delete existing map feature.
|
|
1489
|
+
* @memberof Map
|
|
1490
|
+
* @name deleteFeature
|
|
1491
|
+
* @param id {string} feature id
|
|
1492
|
+
* @example
|
|
1493
|
+
* const map = new Proximiio.Map();
|
|
1494
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1495
|
+
* console.log('map ready', ready);
|
|
1496
|
+
* map.deleteFeature('poiId');
|
|
1497
|
+
* });
|
|
1498
|
+
*/
|
|
1499
|
+
Map.prototype.deleteFeature = function (id) {
|
|
1500
|
+
return this.onDeleteFeature(id);
|
|
1501
|
+
};
|
|
1502
|
+
/**
|
|
1503
|
+
* This method will return list of custom added points.
|
|
1504
|
+
* @memberof Map
|
|
1505
|
+
* @name getCustomFeaturesList
|
|
1506
|
+
* @return {FeatureCollection} of custom features
|
|
1507
|
+
* @example
|
|
1508
|
+
* const map = new Proximiio.Map();
|
|
1509
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1510
|
+
* console.log('map ready', ready);
|
|
1511
|
+
* const features = map.getCustomFeaturesList();
|
|
1512
|
+
* });
|
|
1513
|
+
*/
|
|
1514
|
+
Map.prototype.getCustomFeaturesList = function () {
|
|
1515
|
+
return this.state.dynamicFeatures;
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* @memberof Map
|
|
1519
|
+
* @name getFeatureAddListener
|
|
1520
|
+
* @returns returns feature add listener
|
|
1521
|
+
* @example
|
|
1522
|
+
* const map = new Proximiio.Map();
|
|
1523
|
+
* map.getFeatureAddListener().subscribe(feature => {
|
|
1524
|
+
* console.log('feature added', feature);
|
|
1525
|
+
* });
|
|
1526
|
+
*/
|
|
1527
|
+
Map.prototype.getFeatureAddListener = function () {
|
|
1528
|
+
return this.onFeatureAddListener.asObservable();
|
|
1529
|
+
};
|
|
1530
|
+
/**
|
|
1531
|
+
* @memberof Map
|
|
1532
|
+
* @name getFeatureUpdateListener
|
|
1533
|
+
* @returns returns feature update listener
|
|
1534
|
+
* @example
|
|
1535
|
+
* const map = new Proximiio.Map();
|
|
1536
|
+
* map.getFeatureUpdateListener().subscribe(feature => {
|
|
1537
|
+
* console.log('feature updated', feature);
|
|
1538
|
+
* });
|
|
1539
|
+
*/
|
|
1540
|
+
Map.prototype.getFeatureUpdateListener = function () {
|
|
1541
|
+
return this.onFeatureUpdateListener.asObservable();
|
|
1542
|
+
};
|
|
1543
|
+
/**
|
|
1544
|
+
* @memberof Map
|
|
1545
|
+
* @name getFeatureDeleteListener
|
|
1546
|
+
* @returns returns feature delete listener
|
|
1547
|
+
* @example
|
|
1548
|
+
* const map = new Proximiio.Map();
|
|
1549
|
+
* map.getFeatureDeleteListener().subscribe(() => {
|
|
1550
|
+
* console.log('feature deleted');
|
|
1551
|
+
* });
|
|
1552
|
+
*/
|
|
1553
|
+
Map.prototype.getFeatureDeleteListener = function () {
|
|
1554
|
+
return this.onFeatureDeleteListener.asObservable();
|
|
1555
|
+
};
|
|
1556
|
+
/**
|
|
1557
|
+
* This method will set new kiosk settings.
|
|
1558
|
+
* @memberof Map
|
|
1559
|
+
* @name setKiosk
|
|
1560
|
+
* @param lat {number} latitude coordinate for kiosk position
|
|
1561
|
+
* @param lng {number} longitude coordinate for kiosk position
|
|
1562
|
+
* @param level {number} floor level for kiosk position
|
|
1563
|
+
* @example
|
|
1564
|
+
* const map = new Proximiio.Map({
|
|
1565
|
+
* isKiosk: true,
|
|
1566
|
+
* kioskSettings: {
|
|
1567
|
+
* coordinates: [17.833135351538658, 48.60678469647394],
|
|
1568
|
+
* level: 0
|
|
1569
|
+
* }
|
|
1570
|
+
* });
|
|
1571
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1572
|
+
* console.log('map ready', ready);
|
|
1573
|
+
* map.setKiosk(48.606703739771774, 17.833092384506614, 0);
|
|
1574
|
+
* });
|
|
1575
|
+
*/
|
|
1576
|
+
Map.prototype.setKiosk = function (lat, lng, level) {
|
|
1577
|
+
if (this.defaultOptions.isKiosk) {
|
|
1578
|
+
this.onSetKiosk(lat, lng, level);
|
|
1579
|
+
}
|
|
1580
|
+
else {
|
|
1581
|
+
throw new Error("Map is not initiated as kiosk");
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
/**
|
|
1585
|
+
* You'll be able to show features only for defined amenity id on map with this method, also with defining the category (NOTE: you have to create them before with setAmenitiesCategory() method), filtering will be set only for defined array of amenities in the category. With category set, only one amenity filter can be active at the time, while without the category they stack so multiple amenities can be active.
|
|
1586
|
+
* @memberof Map
|
|
1587
|
+
* @name setAmenityFilter
|
|
1588
|
+
* @param amenityId {string} only features of defined amenityId will be visible
|
|
1589
|
+
* @param category {string} id of the amenities category added via setAmenitiesCategory, optional, if defined filtering will be set only for defined array of amenities in same method
|
|
1590
|
+
* @example
|
|
1591
|
+
* const map = new Proximiio.Map();
|
|
1592
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1593
|
+
* console.log('map ready', ready);
|
|
1594
|
+
* map.setAmenityFilter('myamenity');
|
|
1595
|
+
* });
|
|
1596
|
+
*/
|
|
1597
|
+
Map.prototype.setAmenityFilter = function (amenityId, category) {
|
|
1598
|
+
if (!category || (category && this.amenityCategories[category])) {
|
|
1599
|
+
this.onSetAmenityFilter(amenityId, category);
|
|
1600
|
+
}
|
|
1601
|
+
else {
|
|
1602
|
+
throw new Error("It seems there is no '" + category + "' amenities category created, please set category with 'setAmenitiesCategory()' method");
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
/**
|
|
1606
|
+
* Method for removing previously created amenity filters. In case amenity filter has been set with the category parameter, you have to use same param for removing the filter.
|
|
1607
|
+
* @memberof Map
|
|
1608
|
+
* @name removeAmenityFilter
|
|
1609
|
+
* @param amenityId {string} remove the filter for a defined amenityId
|
|
1610
|
+
* @param category {string} id of the amenities category added via setAmenitiesCategory, optional, if defined filtering will be removed only for defined array of amenities in same method
|
|
1611
|
+
* @example
|
|
1612
|
+
* const map = new Proximiio.Map();
|
|
1613
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1614
|
+
* console.log('map ready', ready);
|
|
1615
|
+
* map.removeAmenityFilter('myamenity');
|
|
1616
|
+
* });
|
|
1617
|
+
*/
|
|
1618
|
+
Map.prototype.removeAmenityFilter = function (amenityId, category) {
|
|
1619
|
+
if (!category || (category && this.amenityCategories[category])) {
|
|
1620
|
+
this.onRemoveAmenityFilter(amenityId, category);
|
|
1621
|
+
}
|
|
1622
|
+
else {
|
|
1623
|
+
throw new Error("It seems there is no '" + category + "' amenities category created, please set category with 'setAmenitiesCategory()' method");
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
/**
|
|
1627
|
+
* Method for removing all active filters.
|
|
1628
|
+
* @memberof Map
|
|
1629
|
+
* @name resetAmenityFilters
|
|
1630
|
+
* @example
|
|
1631
|
+
* const map = new Proximiio.Map();
|
|
1632
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1633
|
+
* console.log('map ready', ready);
|
|
1634
|
+
* map.resetAmenityFilters();
|
|
1635
|
+
* });
|
|
1636
|
+
*/
|
|
1637
|
+
Map.prototype.resetAmenityFilters = function () {
|
|
1638
|
+
this.onResetAmenityFilters();
|
|
1639
|
+
};
|
|
1640
|
+
/**
|
|
1641
|
+
* You can define your own categories of amenities, which you can then use for advanced filtering.
|
|
1642
|
+
* @memberof Map
|
|
1643
|
+
* @name setAmenitiesCategory
|
|
1644
|
+
* @param id {string} category id, have to be used when calling setAmenityFilter() method as second param.
|
|
1645
|
+
* @param amenities {Array of strings} list of the amenities id
|
|
1646
|
+
* @example
|
|
1647
|
+
* const map = new Proximiio.Map();
|
|
1648
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1649
|
+
* console.log('map ready', ready);
|
|
1650
|
+
* map.setAmenitiesCategory('shops', ['id1', 'id2']);
|
|
1651
|
+
* });
|
|
1652
|
+
*/
|
|
1653
|
+
Map.prototype.setAmenitiesCategory = function (id, amenities) {
|
|
1654
|
+
this.amenityCategories[id] = {
|
|
1655
|
+
amenities: amenities,
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
/**
|
|
1659
|
+
* Method for removing previously created categories.
|
|
1660
|
+
* @memberof Map
|
|
1661
|
+
* @name removeAmenitiesCategory
|
|
1662
|
+
* @param id {string} category id.
|
|
1663
|
+
* @example
|
|
1664
|
+
* const map = new Proximiio.Map();
|
|
1665
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1666
|
+
* console.log('map ready', ready);
|
|
1667
|
+
* map.removeAmenitiesCategory('shops');
|
|
1668
|
+
* });
|
|
1669
|
+
*/
|
|
1670
|
+
Map.prototype.removeAmenitiesCategory = function (id) {
|
|
1671
|
+
if (this.amenityCategories[id]) {
|
|
1672
|
+
delete this.amenityCategories[id];
|
|
1673
|
+
}
|
|
1674
|
+
else {
|
|
1675
|
+
throw new Error("It seems there is no '" + id + "' amenities category created, please set category with 'setAmenitiesCategory()' method");
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
/**
|
|
1679
|
+
* Method for removing all active amenity categories.
|
|
1680
|
+
* @memberof Map
|
|
1681
|
+
* @name resetAmenitiesCategory
|
|
1682
|
+
* @example
|
|
1683
|
+
* const map = new Proximiio.Map();
|
|
1684
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1685
|
+
* console.log('map ready', ready);
|
|
1686
|
+
* map.resetAmenitiesCategory();
|
|
1687
|
+
* });
|
|
1688
|
+
*/
|
|
1689
|
+
Map.prototype.resetAmenitiesCategory = function () {
|
|
1690
|
+
this.amenityCategories = {};
|
|
1691
|
+
};
|
|
1692
|
+
/**
|
|
1693
|
+
* @memberof Map
|
|
1694
|
+
* @name getPolygonClickListener
|
|
1695
|
+
* @returns returns polygon click listener
|
|
1696
|
+
* @example
|
|
1697
|
+
* const map = new Proximiio.Map();
|
|
1698
|
+
* map.getPolygonClickListener().subscribe((poi) => {
|
|
1699
|
+
* console.log('polygon clicked', poi);
|
|
1700
|
+
* });
|
|
1701
|
+
*/
|
|
1702
|
+
Map.prototype.getPolygonClickListener = function () {
|
|
1703
|
+
return this.onPolygonClickListener.asObservable();
|
|
1704
|
+
};
|
|
1705
|
+
/**
|
|
1706
|
+
* Method for setting a person icon on a Map, this method is resetting the previous state of all persons added before
|
|
1707
|
+
* @memberof Map
|
|
1708
|
+
* @name setPerson
|
|
1709
|
+
* @param lat {number} latitude coordinate of person.
|
|
1710
|
+
* @param lng {number} longitude coordinate of person.
|
|
1711
|
+
* @param level {number} floor level of person.
|
|
1712
|
+
* @param id {string | number} id of person, optional.
|
|
1713
|
+
* @example
|
|
1714
|
+
* const map = new Proximiio.Map();
|
|
1715
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1716
|
+
* console.log('map ready', ready);
|
|
1717
|
+
* map.setPerson(48.606703739771774, 17.833092384506614, 0);
|
|
1718
|
+
* });
|
|
1719
|
+
*/
|
|
1720
|
+
Map.prototype.setPerson = function (lat, lng, level, id) {
|
|
1721
|
+
this.onSetPerson(lat, lng, level, id);
|
|
1722
|
+
};
|
|
1723
|
+
/**
|
|
1724
|
+
* Method for add/update person icon on a Map
|
|
1725
|
+
* @memberof Map
|
|
1726
|
+
* @name upsertPerson
|
|
1727
|
+
* @param lat {number} latitude coordinate of person.
|
|
1728
|
+
* @param lng {number} longitude coordinate of person.
|
|
1729
|
+
* @param level {number} floor level of person.
|
|
1730
|
+
* @param id {string | number} id of person, optional.
|
|
1731
|
+
* @example
|
|
1732
|
+
* const map = new Proximiio.Map();
|
|
1733
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
1734
|
+
* console.log('map ready', ready);
|
|
1735
|
+
* map.upsertPerson(48.606703739771774, 17.833092384506614, 0, 'person-1');
|
|
1736
|
+
* });
|
|
1737
|
+
*/
|
|
1738
|
+
Map.prototype.upsertPerson = function (lat, lng, level, id) {
|
|
1739
|
+
var person = id ? this.state.persons.find(function (p) { return p.id === id; }) : null;
|
|
1740
|
+
if (person) {
|
|
1741
|
+
this.onUpdatePerson(person, lat, lng, level);
|
|
1742
|
+
}
|
|
1743
|
+
else {
|
|
1744
|
+
this.onAddPerson(lat, lng, level, id);
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
/**
|
|
1748
|
+
* @memberof Map
|
|
1749
|
+
* @name getPersonUpdateListener
|
|
1750
|
+
* @returns returns person update listener
|
|
1751
|
+
* @example
|
|
1752
|
+
* const map = new Proximiio.Map();
|
|
1753
|
+
* map.getPersonUpdateListener().subscribe((personsList) => {
|
|
1754
|
+
* console.log('current persons', personsList);
|
|
1755
|
+
* });
|
|
1756
|
+
*/
|
|
1757
|
+
Map.prototype.getPersonUpdateListener = function () {
|
|
1758
|
+
return this.onPersonUpdateListener.asObservable();
|
|
1759
|
+
};
|
|
1760
|
+
return Map;
|
|
1761
|
+
}());
|
|
1762
|
+
exports.Map = Map;
|
|
1763
|
+
/* TODO
|
|
1764
|
+
* - check clusters
|
|
1765
|
+
* */
|