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,424 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
14
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
15
|
+
to[j] = from[i];
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var base_layer_1 = require("../components/map/layers/base_layer");
|
|
20
|
+
var background_layer_1 = require("../components/map/layers/background_layer");
|
|
21
|
+
var raster_layer_1 = require("../components/map/layers/raster_layer");
|
|
22
|
+
var fill_layer_1 = require("../components/map/layers/fill_layer");
|
|
23
|
+
var line_layer_1 = require("../components/map/layers/line_layer");
|
|
24
|
+
var fill_extrusion_layer_1 = require("../components/map/layers/fill_extrusion_layer");
|
|
25
|
+
var symbol_layer_1 = require("../components/map/layers/symbol_layer");
|
|
26
|
+
var heatmap_layer_1 = require("../components/map/layers/heatmap_layer");
|
|
27
|
+
var circle_layer_1 = require("../components/map/layers/circle_layer");
|
|
28
|
+
var hillshade_layer_1 = require("../components/map/layers/hillshade_layer");
|
|
29
|
+
var deep_diff_1 = require("deep-diff");
|
|
30
|
+
var constants_1 = require("../components/map/constants");
|
|
31
|
+
var metadata_1 = require("../components/map/metadata");
|
|
32
|
+
var StyleModel = /** @class */ (function () {
|
|
33
|
+
function StyleModel(data) {
|
|
34
|
+
this._observers = [];
|
|
35
|
+
this.overlay = false;
|
|
36
|
+
this.segments = false;
|
|
37
|
+
this.routable = false;
|
|
38
|
+
this.cluster = true;
|
|
39
|
+
this.rooms = true;
|
|
40
|
+
// super();
|
|
41
|
+
this.id = data.id;
|
|
42
|
+
this.organization_id = data.organization_id;
|
|
43
|
+
this.version = data.version || 1;
|
|
44
|
+
this.name = data.name || 'New Style';
|
|
45
|
+
this.metadata = Object.assign(metadata_1.default, data.metadata || {});
|
|
46
|
+
this.center = data.center || [18.555, 48.4437];
|
|
47
|
+
this.zoom = data.zoom || 8;
|
|
48
|
+
this.bearing = data.bearing || 0;
|
|
49
|
+
this.pitch = data.pitch || 0;
|
|
50
|
+
this.sources = data.sources || [];
|
|
51
|
+
this.glyphs = data.glyphs || '';
|
|
52
|
+
this.layers = (data.layers || [])
|
|
53
|
+
.map(function (layer) {
|
|
54
|
+
if (layer.type === 'background') {
|
|
55
|
+
return new background_layer_1.default(layer).json;
|
|
56
|
+
}
|
|
57
|
+
if (layer.type === 'raster') {
|
|
58
|
+
return new raster_layer_1.default(layer).json;
|
|
59
|
+
}
|
|
60
|
+
if (layer.type === 'fill') {
|
|
61
|
+
return new fill_layer_1.default(layer).json;
|
|
62
|
+
}
|
|
63
|
+
if (layer.type === 'line') {
|
|
64
|
+
return new line_layer_1.default(layer).json;
|
|
65
|
+
}
|
|
66
|
+
if (layer.type === 'fill-extrusion') {
|
|
67
|
+
return new fill_extrusion_layer_1.default(layer).json;
|
|
68
|
+
}
|
|
69
|
+
if (layer.type === 'symbol') {
|
|
70
|
+
return new symbol_layer_1.default(layer).json;
|
|
71
|
+
}
|
|
72
|
+
if (layer.type === 'heatmap') {
|
|
73
|
+
return new heatmap_layer_1.default(layer).json;
|
|
74
|
+
}
|
|
75
|
+
if (layer.type === 'circle') {
|
|
76
|
+
return new circle_layer_1.default(layer).json;
|
|
77
|
+
}
|
|
78
|
+
if (layer.type === 'hillshade') {
|
|
79
|
+
return new hillshade_layer_1.default(layer).json;
|
|
80
|
+
}
|
|
81
|
+
return new base_layer_1.default(layer);
|
|
82
|
+
})
|
|
83
|
+
.concat(this.getUniversalLayers('main'))
|
|
84
|
+
.concat(this.getSyntheticLayers());
|
|
85
|
+
}
|
|
86
|
+
StyleModel.prototype.on = function (observer) {
|
|
87
|
+
if (this._observers) {
|
|
88
|
+
this._observers.push(observer);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
StyleModel.prototype.off = function (observer) {
|
|
92
|
+
var index = this._observers ? this._observers.findIndex(function (o) { return o === observer; }) : 0;
|
|
93
|
+
if (index >= 0) {
|
|
94
|
+
if (this._observers) {
|
|
95
|
+
this._observers.splice(index, 1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
StyleModel.prototype.notify = function (event, data) {
|
|
100
|
+
var _this = this;
|
|
101
|
+
if (this._observers) {
|
|
102
|
+
this._observers.forEach(function (observer) { return observer(event, data, _this); });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
StyleModel.prototype.getUniversalLayers = function (source) {
|
|
106
|
+
var filter = [
|
|
107
|
+
'all',
|
|
108
|
+
['==', ['geometry-type'], 'Polygon'],
|
|
109
|
+
['any', ['==', ['get', 'segment'], false], ['!', ['has', 'segment']]],
|
|
110
|
+
['any', ['==', ['get', 'routable'], false], ['!', ['has', 'routable']]],
|
|
111
|
+
['==', ['get', 'level'], 0],
|
|
112
|
+
];
|
|
113
|
+
var segmentFilter = [
|
|
114
|
+
'all',
|
|
115
|
+
['==', ['geometry-type'], 'Polygon'],
|
|
116
|
+
['has', 'segment'],
|
|
117
|
+
['==', ['get', 'segment'], true],
|
|
118
|
+
['==', ['get', 'level'], 0],
|
|
119
|
+
];
|
|
120
|
+
var routableFilter = [
|
|
121
|
+
'all',
|
|
122
|
+
['==', ['geometry-type'], 'Polygon'],
|
|
123
|
+
['has', 'routable'],
|
|
124
|
+
['==', ['get', 'routable'], true],
|
|
125
|
+
['==', ['get', 'level'], 0],
|
|
126
|
+
];
|
|
127
|
+
var roomFilter = [
|
|
128
|
+
'all',
|
|
129
|
+
['==', ['geometry-type'], 'Polygon'],
|
|
130
|
+
['has', 'room'],
|
|
131
|
+
['==', ['get', 'room'], true],
|
|
132
|
+
['==', ['get', 'level'], 0],
|
|
133
|
+
];
|
|
134
|
+
var base = {
|
|
135
|
+
minzoom: 1,
|
|
136
|
+
maxzoom: 24,
|
|
137
|
+
source: source,
|
|
138
|
+
};
|
|
139
|
+
return [
|
|
140
|
+
new fill_layer_1.default(__assign(__assign({}, base), { id: source + "-polygon-fill", type: 'fill', filter: filter, layout: {
|
|
141
|
+
visibility: 'none',
|
|
142
|
+
}, paint: {
|
|
143
|
+
'fill-color': '#08c',
|
|
144
|
+
'fill-opacity': 0.3,
|
|
145
|
+
} })).json,
|
|
146
|
+
new line_layer_1.default(__assign(__assign({}, base), { id: source + "-polygon-outline", type: 'line', filter: filter, layout: {
|
|
147
|
+
'line-join': 'bevel',
|
|
148
|
+
visibility: 'none',
|
|
149
|
+
}, paint: {
|
|
150
|
+
'line-color': '#08c',
|
|
151
|
+
'line-width': 1,
|
|
152
|
+
'line-opacity': 1,
|
|
153
|
+
} })).json,
|
|
154
|
+
new line_layer_1.default(__assign(__assign({}, base), { id: source + "-room-outline", type: 'line', roomFilter: roomFilter, layout: {
|
|
155
|
+
'line-join': 'bevel',
|
|
156
|
+
visibility: 'none',
|
|
157
|
+
}, paint: {
|
|
158
|
+
'line-color': ['get', 'color'],
|
|
159
|
+
'line-width': 1,
|
|
160
|
+
'line-opacity': 1,
|
|
161
|
+
} })).json,
|
|
162
|
+
new fill_layer_1.default(__assign(__assign({}, base), { id: source + "-room-fill", type: 'fill', filter: roomFilter, layout: {
|
|
163
|
+
visibility: 'none',
|
|
164
|
+
}, paint: {
|
|
165
|
+
'fill-color': ['get', 'color'],
|
|
166
|
+
'fill-opacity': 0.3,
|
|
167
|
+
} })).json,
|
|
168
|
+
// segments
|
|
169
|
+
new fill_layer_1.default(__assign(__assign({}, base), { id: source + "-segment-fill", type: 'fill', filter: segmentFilter, layout: {
|
|
170
|
+
visibility: 'none',
|
|
171
|
+
}, paint: {
|
|
172
|
+
'fill-color': '#0c8',
|
|
173
|
+
'fill-opacity': 0.3,
|
|
174
|
+
} })).json,
|
|
175
|
+
new line_layer_1.default(__assign(__assign({}, base), { id: source + "-segment-outline", type: 'line', filter: segmentFilter, layout: {
|
|
176
|
+
'line-join': 'bevel',
|
|
177
|
+
visibility: 'none',
|
|
178
|
+
}, paint: {
|
|
179
|
+
'line-color': '#0c8',
|
|
180
|
+
'line-width': 1,
|
|
181
|
+
'line-opacity': 1,
|
|
182
|
+
} })).json,
|
|
183
|
+
// routables
|
|
184
|
+
new fill_layer_1.default(__assign(__assign({}, base), { id: source + "-routable-fill", type: 'fill', filter: routableFilter, layout: {
|
|
185
|
+
visibility: 'none',
|
|
186
|
+
}, paint: {
|
|
187
|
+
'fill-color': '#c80',
|
|
188
|
+
'fill-opacity': 0.3,
|
|
189
|
+
} })).json,
|
|
190
|
+
new line_layer_1.default(__assign(__assign({}, base), { id: source + "-routable-outline", type: 'line', filter: routableFilter, layout: {
|
|
191
|
+
'line-join': 'bevel',
|
|
192
|
+
visibility: 'none',
|
|
193
|
+
}, paint: {
|
|
194
|
+
'line-color': '#c80',
|
|
195
|
+
'line-width': 1,
|
|
196
|
+
'line-opacity': 1,
|
|
197
|
+
} })).json,
|
|
198
|
+
];
|
|
199
|
+
};
|
|
200
|
+
StyleModel.prototype.getSyntheticLayers = function () {
|
|
201
|
+
var polygonFill = new fill_layer_1.default({
|
|
202
|
+
type: 'fill',
|
|
203
|
+
minzoom: 1,
|
|
204
|
+
maxzoom: 24,
|
|
205
|
+
source: 'synthetic',
|
|
206
|
+
id: 'synthetic-polygon-fill',
|
|
207
|
+
filter: ['all', ['==', ['geometry-type'], 'Polygon']],
|
|
208
|
+
layout: {
|
|
209
|
+
visibility: 'visible',
|
|
210
|
+
},
|
|
211
|
+
paint: {
|
|
212
|
+
'fill-color': '#08c',
|
|
213
|
+
'fill-opacity': 0.3,
|
|
214
|
+
},
|
|
215
|
+
}).json;
|
|
216
|
+
var polygonOutline = new line_layer_1.default({
|
|
217
|
+
type: 'line',
|
|
218
|
+
minzoom: 1,
|
|
219
|
+
maxzoom: 24,
|
|
220
|
+
source: 'synthetic',
|
|
221
|
+
id: 'synthetic-polygon-outline',
|
|
222
|
+
filter: ['all', ['==', ['geometry-type'], 'Polygon']],
|
|
223
|
+
layout: {
|
|
224
|
+
'line-join': 'bevel',
|
|
225
|
+
visibility: 'visible',
|
|
226
|
+
},
|
|
227
|
+
paint: {
|
|
228
|
+
'line-color': '#08c',
|
|
229
|
+
'line-width': 1,
|
|
230
|
+
'line-opacity': 1,
|
|
231
|
+
},
|
|
232
|
+
}).json;
|
|
233
|
+
return [polygonFill, polygonOutline];
|
|
234
|
+
};
|
|
235
|
+
StyleModel.prototype.usesPrefixes = function () {
|
|
236
|
+
return typeof this.layers.find(function (layer) { return layer.id === 'proximiio-paths'; }) !== 'undefined';
|
|
237
|
+
};
|
|
238
|
+
StyleModel.prototype.addLayer = function (layer) {
|
|
239
|
+
this.layers.push(layer);
|
|
240
|
+
};
|
|
241
|
+
StyleModel.prototype.getLayer = function (id) {
|
|
242
|
+
return this.layers.find(function (layer) { return layer.id === id; });
|
|
243
|
+
};
|
|
244
|
+
StyleModel.prototype.getLayerIndex = function (id) {
|
|
245
|
+
return this.layers.findIndex(function (layer) { return layer.id === id; });
|
|
246
|
+
};
|
|
247
|
+
StyleModel.prototype.getLayers = function (sourceId) {
|
|
248
|
+
return this.layers.filter(function (layer) { return layer.source && layer.source === sourceId; });
|
|
249
|
+
};
|
|
250
|
+
StyleModel.prototype.addSource = function (sourceId, source) {
|
|
251
|
+
this.sources[sourceId] = source;
|
|
252
|
+
};
|
|
253
|
+
StyleModel.prototype.getSources = function () {
|
|
254
|
+
var _this = this;
|
|
255
|
+
var sources = [];
|
|
256
|
+
Object.keys(this.sources).forEach(function (id) {
|
|
257
|
+
var source = _this.sources[id];
|
|
258
|
+
source.id = id;
|
|
259
|
+
sources.push(source);
|
|
260
|
+
});
|
|
261
|
+
return sources;
|
|
262
|
+
};
|
|
263
|
+
StyleModel.prototype.setSource = function (id, data) {
|
|
264
|
+
this.sources[id] = data.source;
|
|
265
|
+
};
|
|
266
|
+
StyleModel.prototype.setLevel = function (level) {
|
|
267
|
+
__spreadArray(__spreadArray([], this.getLayers('main')), this.getLayers('route')).forEach(function (layer) {
|
|
268
|
+
if (!layer.filter) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
layer.filter.forEach(function (filter, filterIndex) {
|
|
272
|
+
if (layer.id === 'proximiio-levelchangers') {
|
|
273
|
+
var lvl = "__level_" + level;
|
|
274
|
+
if (filterIndex === 3) {
|
|
275
|
+
filter[1] = lvl;
|
|
276
|
+
}
|
|
277
|
+
if (filterIndex === 4) {
|
|
278
|
+
filter[1][1] = lvl;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(filter)) {
|
|
282
|
+
var changed = false;
|
|
283
|
+
if (filter[0] === '==') {
|
|
284
|
+
var expression = filter[1];
|
|
285
|
+
if (expression[0] === 'to-number') {
|
|
286
|
+
if (expression[1][0] === 'get' && expression[1][1] === 'level') {
|
|
287
|
+
filter[2] = level;
|
|
288
|
+
changed = true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (expression[0] === 'get' && expression[1] === 'level') {
|
|
292
|
+
filter[2] = level;
|
|
293
|
+
changed = true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (filter[0] === '<=') {
|
|
297
|
+
var expression = filter[1];
|
|
298
|
+
if (expression[0] === 'to-number') {
|
|
299
|
+
if (expression[1][0] === 'get' && expression[1][1] === 'level_min') {
|
|
300
|
+
filter[2] = level;
|
|
301
|
+
changed = true;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (expression[0] === 'get' && expression[1] === 'level_min') {
|
|
305
|
+
filter[2] = level;
|
|
306
|
+
changed = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (filter[0] === '>=') {
|
|
310
|
+
var expression = filter[1];
|
|
311
|
+
if (expression[0] === 'to-number') {
|
|
312
|
+
if (expression[1][0] === 'get' && expression[1][1] === 'level_max') {
|
|
313
|
+
filter[2] = level;
|
|
314
|
+
changed = true;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (expression[0] === 'get' && expression[1] === 'level_max') {
|
|
318
|
+
filter[2] = level;
|
|
319
|
+
changed = true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (changed) {
|
|
323
|
+
layer.filter[filterIndex] = filter;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
this.notify('filter-change');
|
|
329
|
+
};
|
|
330
|
+
Object.defineProperty(StyleModel.prototype, "polygonEditing", {
|
|
331
|
+
get: function () {
|
|
332
|
+
return this.metadata[constants_1.METADATA_POLYGON_EDITING] || false;
|
|
333
|
+
},
|
|
334
|
+
enumerable: false,
|
|
335
|
+
configurable: true
|
|
336
|
+
});
|
|
337
|
+
StyleModel.prototype.toggleCluster = function () {
|
|
338
|
+
this.cluster = !this.cluster;
|
|
339
|
+
this.notify('cluster-toggled');
|
|
340
|
+
};
|
|
341
|
+
StyleModel.prototype.togglePolygonEditing = function () {
|
|
342
|
+
if (this.metadata[constants_1.METADATA_POLYGON_EDITING]) {
|
|
343
|
+
this.metadata[constants_1.METADATA_POLYGON_EDITING] = !this.metadata[constants_1.METADATA_POLYGON_EDITING];
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this.metadata[constants_1.METADATA_POLYGON_EDITING] = true;
|
|
347
|
+
}
|
|
348
|
+
console.log('polygon-editing-toggled', this.metadata[constants_1.METADATA_POLYGON_EDITING]);
|
|
349
|
+
this.notify('polygon-editing-toggled');
|
|
350
|
+
};
|
|
351
|
+
StyleModel.prototype.toggleRooms = function () {
|
|
352
|
+
this.rooms = !this.rooms;
|
|
353
|
+
this.notify('roomsss-toggled');
|
|
354
|
+
};
|
|
355
|
+
StyleModel.prototype.toggleOverlay = function () {
|
|
356
|
+
this.overlay = !this.overlay;
|
|
357
|
+
this.notify('overlay-toggled');
|
|
358
|
+
};
|
|
359
|
+
StyleModel.prototype.toggleSegments = function () {
|
|
360
|
+
this.segments = !this.segments;
|
|
361
|
+
this.notify('segments-toggled');
|
|
362
|
+
};
|
|
363
|
+
StyleModel.prototype.toggleRoutable = function () {
|
|
364
|
+
this.routable = !this.routable;
|
|
365
|
+
this.notify('routable-toggled');
|
|
366
|
+
};
|
|
367
|
+
StyleModel.prototype.togglePaths = function (enabled) {
|
|
368
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
369
|
+
var layer = this.layers.find(function (layer) { return layer.id === 'proximiio-paths' || layer.id === 'paths'; });
|
|
370
|
+
if (layer) {
|
|
371
|
+
var updated = new line_layer_1.default(Object.assign({}, layer.json));
|
|
372
|
+
updated.layout.visibility = enabled ? 'visible' : 'none';
|
|
373
|
+
this.updateLayer(updated);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
StyleModel.prototype.updateLayer = function (layer) {
|
|
377
|
+
// debug.log('style updateLayer in:', layer)
|
|
378
|
+
var idx = this.getLayerIndex(layer.id);
|
|
379
|
+
var changes = [];
|
|
380
|
+
if (idx >= 0) {
|
|
381
|
+
var prev = this.layers[idx];
|
|
382
|
+
var change = deep_diff_1.diff(prev.json, layer.json);
|
|
383
|
+
console.log('change', change);
|
|
384
|
+
if (change) {
|
|
385
|
+
changes.push(change);
|
|
386
|
+
this.layers.splice(idx, 1, layer);
|
|
387
|
+
// debug.log('style should update layer', layer, 'changes', changes)
|
|
388
|
+
this.notify('layer-update', { layer: layer, changes: changes.length > 0 ? changes[0] : [] });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
StyleModel.prototype.setMetadata = function (namespace, item, value) {
|
|
393
|
+
this.metadata[namespace + ":" + item] = value;
|
|
394
|
+
this.notify('metadata-update');
|
|
395
|
+
};
|
|
396
|
+
Object.defineProperty(StyleModel.prototype, "namespaces", {
|
|
397
|
+
get: function () {
|
|
398
|
+
var keys = Object.keys(this.metadata);
|
|
399
|
+
var pairs = keys.filter(function (key) { return key.indexOf(':') > 0; });
|
|
400
|
+
var unique = new Set(pairs.map(function (pair) { return pair.split(':')[0]; }));
|
|
401
|
+
return Array.from(unique).sort(function (a, b) { return a.localeCompare(b); });
|
|
402
|
+
},
|
|
403
|
+
enumerable: false,
|
|
404
|
+
configurable: true
|
|
405
|
+
});
|
|
406
|
+
StyleModel.prototype.namespaceItems = function (namespace) {
|
|
407
|
+
return Object.keys(this.metadata)
|
|
408
|
+
.filter(function (key) { return key.indexOf(namespace + ":") === 0; })
|
|
409
|
+
.map(function (key) { return key.split(':').slice(1).join(':'); });
|
|
410
|
+
};
|
|
411
|
+
Object.defineProperty(StyleModel.prototype, "json", {
|
|
412
|
+
get: function () {
|
|
413
|
+
var style = Object.assign({}, this);
|
|
414
|
+
delete style._observers;
|
|
415
|
+
delete style.overlay;
|
|
416
|
+
style.layers = this.layers.map(function (layer) { return layer.json; });
|
|
417
|
+
return JSON.parse(JSON.stringify(style));
|
|
418
|
+
},
|
|
419
|
+
enumerable: false,
|
|
420
|
+
configurable: true
|
|
421
|
+
});
|
|
422
|
+
return StyleModel;
|
|
423
|
+
}());
|
|
424
|
+
exports.default = StyleModel;
|