mobility-toolbox-js 2.0.0-beta.52 → 2.0.0-beta.53
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 +26 -3
- package/api/RealtimeAPI.d.ts +8 -3
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +4 -1
- package/common/controls/ControlCommon.d.ts +1 -1
- package/common/controls/ControlCommon.d.ts.map +1 -1
- package/common/layers/LayerCommon.d.ts +1 -0
- package/common/layers/LayerCommon.d.ts.map +1 -1
- package/common/layers/LayerCommon.js +3 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +2 -2
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
- package/common/mixins/UserInteractionsLayerMixin.js +7 -10
- package/common/styles/realtimeDefaultStyle.d.ts +2 -2
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
- package/common/styles/realtimeDelayStyle.d.ts +2 -2
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts +2 -1
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
- package/common/typedefs.js +3 -3
- package/common/utils/{createTrackerFilters.d.ts → createRealtimeFilters.d.ts} +3 -3
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/{createTrackerFilters.js → createRealtimeFilters.js} +2 -2
- package/common/utils/getMapboxRender.d.ts +3 -3
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +2 -1
- package/common/utils/getMaplibreRender.d.ts +3 -1
- package/common/utils/getMaplibreRender.d.ts.map +1 -1
- package/common/utils/getMaplibreRender.js +4 -4
- package/common/utils/getRealtimeModeSuffix.d.ts +4 -2
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
- package/common/utils/getUrlWithParams.d.ts +2 -2
- package/common/utils/getUrlWithParams.d.ts.map +1 -1
- package/common/utils/getVehiclePosition.d.ts +7 -5
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/index.d.ts +2 -2
- package/common/utils/index.js +3 -3
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/{trackerConfig.js → realtimeConfig.js} +17 -17
- package/common/utils/sortByDelay.d.ts +1 -1
- package/common/utils/sortByDelay.d.ts.map +1 -1
- package/common/utils/timeUtils.d.ts +23 -4
- package/common/utils/timeUtils.d.ts.map +1 -1
- package/common/utils/timeUtils.js +1 -1
- package/mbt.js +166 -166
- package/mbt.js.map +3 -3
- package/mbt.min.js +62 -62
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.d.ts +95 -91
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +100 -90
- package/ol/layers/Layer.d.ts +3 -2
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/Layer.js +2 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -1
- package/ol/layers/MapGlLayer.js +3 -5
- package/ol/layers/MapboxLayer.d.ts +1 -1
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +1 -0
- package/ol/layers/MapboxStyleLayer.js +4 -2
- package/ol/layers/MaplibreLayer.d.ts +2 -1
- package/ol/layers/MaplibreLayer.d.ts.map +1 -1
- package/ol/layers/RoutingLayer.d.ts +15 -5
- package/ol/layers/RoutingLayer.d.ts.map +1 -1
- package/ol/layers/RoutingLayer.js +3 -2
- package/ol/styles/fullTrajectoryStyle.d.ts +2 -2
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/common.d.ts +6 -1
- package/common/utils/createTrackerFilters.d.ts.map +0 -1
- package/common/utils/trackerConfig.d.ts +0 -24
- package/common/utils/trackerConfig.d.ts.map +0 -1
|
@@ -7,6 +7,7 @@ import { GeoJSON } from 'ol/format';
|
|
|
7
7
|
import { buffer } from 'ol/extent';
|
|
8
8
|
import { fromLonLat, toLonLat } from 'ol/proj';
|
|
9
9
|
import GeomType from 'ol/geom/GeometryType';
|
|
10
|
+
import BaseEvent from 'ol/events/Event';
|
|
10
11
|
import { RoutingAPI } from '../../api';
|
|
11
12
|
import ControlCommon from '../../common/controls/ControlCommon';
|
|
12
13
|
import RoutingLayer from '../layers/RoutingLayer';
|
|
@@ -36,7 +37,12 @@ const STOP_FETCH_ABORT_CONTROLLER_KEY = 'stop-fetch';
|
|
|
36
37
|
const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
37
38
|
const coords = [];
|
|
38
39
|
segmentArray.forEach((seg) => {
|
|
39
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
const coordArr = (_a = seg.getGeometry()) === null || _a === void 0 ? void 0 : _a.getCoordinates();
|
|
43
|
+
if (coordArr === null || coordArr === void 0 ? void 0 : coordArr.length) {
|
|
44
|
+
coords.push(...coordArr);
|
|
45
|
+
}
|
|
40
46
|
});
|
|
41
47
|
return coords;
|
|
42
48
|
};
|
|
@@ -74,6 +80,17 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
74
80
|
class RoutingControl extends ControlCommon {
|
|
75
81
|
constructor(options = {}) {
|
|
76
82
|
super(options);
|
|
83
|
+
this.viaPoints = [];
|
|
84
|
+
this.loading = false;
|
|
85
|
+
this.graphs = [];
|
|
86
|
+
this.modify = true;
|
|
87
|
+
this.useRawViaPoints = false;
|
|
88
|
+
this.snapToClosestStation = false;
|
|
89
|
+
this.cacheStationData = {};
|
|
90
|
+
this.abortControllers = {};
|
|
91
|
+
this.segments = [];
|
|
92
|
+
this.format = new GeoJSON({ featureProjection: 'EPSG:3857' });
|
|
93
|
+
this.initialRouteDrag = {};
|
|
77
94
|
Object.defineProperties(this, {
|
|
78
95
|
mot: {
|
|
79
96
|
get: () => this.get('mot'),
|
|
@@ -108,22 +125,16 @@ class RoutingControl extends ControlCommon {
|
|
|
108
125
|
/** @ignore */
|
|
109
126
|
this.modify = options.modify !== false;
|
|
110
127
|
/** @ignore */
|
|
111
|
-
this.routingApiParams = options.routingApiParams
|
|
128
|
+
this.routingApiParams = options.routingApiParams;
|
|
112
129
|
/** @ignore */
|
|
113
130
|
this.useRawViaPoints = options.useRawViaPoints || false;
|
|
114
131
|
/** @ignore */
|
|
115
132
|
this.snapToClosestStation = options.snapToClosestStation || false;
|
|
116
133
|
/** @ignore */
|
|
117
|
-
this.cacheStationData = {};
|
|
118
|
-
/** @ignore */
|
|
119
|
-
this.abortControllers = [];
|
|
120
|
-
/** @ignore */
|
|
121
134
|
this.apiKey = options.apiKey;
|
|
122
135
|
/** @ignore */
|
|
123
136
|
this.stopsApiKey = options.stopsApiKey || this.apiKey;
|
|
124
137
|
/** @ignore */
|
|
125
|
-
this.segments = [];
|
|
126
|
-
/** @ignore */
|
|
127
138
|
this.stopsApiUrl = options.stopsApiUrl || 'https://api.geops.io/stops/v1/';
|
|
128
139
|
/** @ignore */
|
|
129
140
|
this.api = new RoutingAPI(Object.assign({}, options));
|
|
@@ -138,25 +149,18 @@ class RoutingControl extends ControlCommon {
|
|
|
138
149
|
this.onRouteError =
|
|
139
150
|
options.onRouteError ||
|
|
140
151
|
((error) => {
|
|
141
|
-
this.dispatchEvent(
|
|
142
|
-
type: 'change:route',
|
|
143
|
-
target: this,
|
|
144
|
-
});
|
|
152
|
+
this.dispatchEvent(new BaseEvent('change:route'));
|
|
145
153
|
this.reset();
|
|
146
154
|
// eslint-disable-next-line no-console
|
|
147
155
|
console.error(error);
|
|
148
156
|
});
|
|
149
157
|
/** @ignore */
|
|
150
|
-
this.viaPoints = [];
|
|
151
|
-
/** @ignore */
|
|
152
158
|
this.onMapClick = this.onMapClick.bind(this);
|
|
153
159
|
/** @ignore */
|
|
154
160
|
this.onModifyEnd = this.onModifyEnd.bind(this);
|
|
155
161
|
/** @ignore */
|
|
156
162
|
this.onModifyStart = this.onModifyStart.bind(this);
|
|
157
163
|
/** @ignore */
|
|
158
|
-
this.apiChangeListener = () => this.drawRoute();
|
|
159
|
-
/** @ignore */
|
|
160
164
|
this.createModifyInteraction();
|
|
161
165
|
}
|
|
162
166
|
/**
|
|
@@ -185,26 +189,20 @@ class RoutingControl extends ControlCommon {
|
|
|
185
189
|
/* Add/Insert/Overwrite viapoint and redraw route */
|
|
186
190
|
this.viaPoints.splice(index === -1 ? this.viaPoints.length : index, overwrite, coordinatesOrString);
|
|
187
191
|
this.drawRoute();
|
|
188
|
-
this.dispatchEvent(
|
|
189
|
-
type: 'change:route',
|
|
190
|
-
target: this,
|
|
191
|
-
});
|
|
192
|
+
this.dispatchEvent(new BaseEvent('change:route'));
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
194
195
|
* Removes a viaPoint at the passed array index and redraws route
|
|
195
196
|
* By default the last viaPoint is removed.
|
|
196
197
|
* @param {number} index Integer representing the index of the viaPoint to delete.
|
|
197
198
|
*/
|
|
198
|
-
removeViaPoint(index = this.viaPoints.length - 1) {
|
|
199
|
+
removeViaPoint(index = (this.viaPoints || []).length - 1) {
|
|
199
200
|
/* Remove viapoint and redraw route */
|
|
200
201
|
if (this.viaPoints.length && this.viaPoints[index]) {
|
|
201
202
|
this.viaPoints.splice(index, 1);
|
|
202
203
|
}
|
|
203
204
|
this.drawRoute();
|
|
204
|
-
this.dispatchEvent(
|
|
205
|
-
type: 'change:route',
|
|
206
|
-
target: this,
|
|
207
|
-
});
|
|
205
|
+
this.dispatchEvent(new BaseEvent('change:route'));
|
|
208
206
|
}
|
|
209
207
|
/**
|
|
210
208
|
* Replaces the current viaPoints with a new coordinate array.
|
|
@@ -213,23 +211,18 @@ class RoutingControl extends ControlCommon {
|
|
|
213
211
|
setViaPoints(coordinateArray) {
|
|
214
212
|
this.viaPoints = [...coordinateArray];
|
|
215
213
|
this.drawRoute();
|
|
216
|
-
this.dispatchEvent(
|
|
217
|
-
type: 'change:route',
|
|
218
|
-
target: this,
|
|
219
|
-
});
|
|
214
|
+
this.dispatchEvent(new BaseEvent('change:route'));
|
|
220
215
|
}
|
|
221
216
|
/**
|
|
222
217
|
* Removes all viaPoints, clears the source and triggers a change event
|
|
223
218
|
*/
|
|
224
219
|
reset() {
|
|
220
|
+
var _a, _b, _c;
|
|
225
221
|
// Clear viaPoints and source
|
|
226
222
|
this.abortRequests();
|
|
227
223
|
this.viaPoints = [];
|
|
228
|
-
this.routingLayer.olLayer.getSource().clear();
|
|
229
|
-
this.dispatchEvent(
|
|
230
|
-
type: 'change:route',
|
|
231
|
-
target: this,
|
|
232
|
-
});
|
|
224
|
+
(_c = (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.clear();
|
|
225
|
+
this.dispatchEvent(new BaseEvent('change:route'));
|
|
233
226
|
}
|
|
234
227
|
/**
|
|
235
228
|
* Aborts viapoint and route requests
|
|
@@ -238,11 +231,12 @@ class RoutingControl extends ControlCommon {
|
|
|
238
231
|
abortRequests() {
|
|
239
232
|
var _a;
|
|
240
233
|
// Abort Routing API requests
|
|
241
|
-
this.graphs.forEach((
|
|
242
|
-
|
|
243
|
-
|
|
234
|
+
this.graphs.forEach((graph) => {
|
|
235
|
+
const graphName = graph[0];
|
|
236
|
+
if (this.abortControllers[graphName]) {
|
|
237
|
+
this.abortControllers[graphName].abort();
|
|
244
238
|
}
|
|
245
|
-
this.abortControllers[
|
|
239
|
+
this.abortControllers[graphName] = new AbortController();
|
|
246
240
|
});
|
|
247
241
|
// Abort Stops API requests
|
|
248
242
|
(_a = this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]) === null || _a === void 0 ? void 0 : _a.abort();
|
|
@@ -258,9 +252,10 @@ class RoutingControl extends ControlCommon {
|
|
|
258
252
|
* @private
|
|
259
253
|
*/
|
|
260
254
|
drawRoute() {
|
|
255
|
+
var _a, _b, _c, _d, _e, _f;
|
|
261
256
|
/* Calls RoutingAPI to draw a route using the viaPoints array */
|
|
262
257
|
this.abortRequests();
|
|
263
|
-
this.routingLayer.olLayer.getSource().clear();
|
|
258
|
+
(_c = (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.clear();
|
|
264
259
|
if (!this.viaPoints.length) {
|
|
265
260
|
return null;
|
|
266
261
|
}
|
|
@@ -269,8 +264,9 @@ class RoutingControl extends ControlCommon {
|
|
|
269
264
|
return this.drawViaPoint(this.viaPoints[0], 0, this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]);
|
|
270
265
|
}
|
|
271
266
|
const formattedViaPoints = this.viaPoints.map((viaPoint) => {
|
|
267
|
+
var _a;
|
|
272
268
|
if (Array.isArray(viaPoint)) {
|
|
273
|
-
const projection = this.map.getView().getProjection();
|
|
269
|
+
const projection = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().getProjection();
|
|
274
270
|
// viaPoint is a coordinate
|
|
275
271
|
// Coordinates need to be reversed as required by the backend RoutingAPI
|
|
276
272
|
const [lon, lat] = toLonLat(viaPoint, projection);
|
|
@@ -281,14 +277,20 @@ class RoutingControl extends ControlCommon {
|
|
|
281
277
|
});
|
|
282
278
|
this.loading = true;
|
|
283
279
|
// Clear source
|
|
284
|
-
this.routingLayer.olLayer.getSource().clear();
|
|
280
|
+
(_f = (_e = (_d = this.routingLayer) === null || _d === void 0 ? void 0 : _d.olLayer) === null || _e === void 0 ? void 0 : _e.getSource()) === null || _f === void 0 ? void 0 : _f.clear();
|
|
285
281
|
// Create point features for the viaPoints
|
|
286
282
|
this.viaPoints.forEach((viaPoint, idx) => this.drawViaPoint(viaPoint, idx, this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]));
|
|
287
283
|
return Promise.all(this.graphs.map(([graph], index) => {
|
|
288
284
|
const { signal } = this.abortControllers[graph];
|
|
285
|
+
if (!this.api) {
|
|
286
|
+
return Promise.resolve([]);
|
|
287
|
+
}
|
|
289
288
|
return this.api
|
|
290
|
-
.route(Object.assign({ graph, via: `${formattedViaPoints.join('|')}`, mot:
|
|
289
|
+
.route(Object.assign({ graph, via: `${formattedViaPoints.join('|')}`, mot: this.mot,
|
|
290
|
+
// @ts-ignore missing property in swagger
|
|
291
|
+
'resolve-hops': false, elevation: false, 'coord-radius': 100.0, 'coord-punish': 1000.0 }, (this.routingApiParams || {})), { signal })
|
|
291
292
|
.then((featureCollection) => {
|
|
293
|
+
var _a, _b, _c, _d;
|
|
292
294
|
this.segments = this.format.readFeatures(featureCollection);
|
|
293
295
|
if (this.mot === 'foot') {
|
|
294
296
|
// Extract unique values from viaPoint target value
|
|
@@ -317,9 +319,12 @@ class RoutingControl extends ControlCommon {
|
|
|
317
319
|
});
|
|
318
320
|
routeFeature.set('graph', graph);
|
|
319
321
|
routeFeature.set('mot', this.mot);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
322
|
+
if (this.graphsResolutions &&
|
|
323
|
+
((_a = this.graphsResolutions[index]) === null || _a === void 0 ? void 0 : _a.length) >= 2) {
|
|
324
|
+
routeFeature.set('minResolution', this.graphsResolutions[index][0]);
|
|
325
|
+
routeFeature.set('maxResolution', this.graphsResolutions[index][1]);
|
|
326
|
+
}
|
|
327
|
+
(_d = (_c = (_b = this.routingLayer) === null || _b === void 0 ? void 0 : _b.olLayer) === null || _c === void 0 ? void 0 : _c.getSource()) === null || _d === void 0 ? void 0 : _d.addFeature(routeFeature);
|
|
323
328
|
this.loading = false;
|
|
324
329
|
})
|
|
325
330
|
.catch((error) => {
|
|
@@ -329,10 +334,7 @@ class RoutingControl extends ControlCommon {
|
|
|
329
334
|
}
|
|
330
335
|
this.segments = [];
|
|
331
336
|
// Dispatch error event and execute error function
|
|
332
|
-
this.dispatchEvent(
|
|
333
|
-
type: 'error',
|
|
334
|
-
target: this,
|
|
335
|
-
});
|
|
337
|
+
this.dispatchEvent(new BaseEvent('error'));
|
|
336
338
|
this.onRouteError(error, this);
|
|
337
339
|
this.loading = false;
|
|
338
340
|
});
|
|
@@ -344,12 +346,13 @@ class RoutingControl extends ControlCommon {
|
|
|
344
346
|
* @private
|
|
345
347
|
*/
|
|
346
348
|
drawViaPoint(viaPoint, idx, abortController) {
|
|
349
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
347
350
|
const pointFeature = new Feature();
|
|
348
351
|
pointFeature.set('viaPointIdx', idx);
|
|
349
352
|
// The via point is a coordinate using the current map's projection
|
|
350
353
|
if (Array.isArray(viaPoint)) {
|
|
351
354
|
pointFeature.setGeometry(new Point(viaPoint));
|
|
352
|
-
this.routingLayer.olLayer.getSource().addFeature(pointFeature);
|
|
355
|
+
(_c = (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.addFeature(pointFeature);
|
|
353
356
|
return Promise.resolve(pointFeature);
|
|
354
357
|
}
|
|
355
358
|
// Possibility to parse:
|
|
@@ -360,7 +363,8 @@ class RoutingControl extends ControlCommon {
|
|
|
360
363
|
let stationId;
|
|
361
364
|
let track;
|
|
362
365
|
if (this.useRawViaPoints) {
|
|
363
|
-
[, stationId, , track] =
|
|
366
|
+
[, stationId, , track] =
|
|
367
|
+
REGEX_VIA_POINT_STATION_ID.exec(viaPoint) || [];
|
|
364
368
|
}
|
|
365
369
|
else {
|
|
366
370
|
[stationId, track] = viaPoint.split('$');
|
|
@@ -368,11 +372,12 @@ class RoutingControl extends ControlCommon {
|
|
|
368
372
|
return fetch(`${this.stopsApiUrl}lookup/${stationId}?key=${this.stopsApiKey}`, { signal: abortController.signal })
|
|
369
373
|
.then((res) => res.json())
|
|
370
374
|
.then((stationData) => {
|
|
375
|
+
var _a, _b, _c;
|
|
371
376
|
const { coordinates } = stationData.features[0].geometry;
|
|
372
377
|
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
373
378
|
pointFeature.set('viaPointTrack', track);
|
|
374
379
|
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
375
|
-
this.routingLayer.olLayer.getSource().addFeature(pointFeature);
|
|
380
|
+
(_c = (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.addFeature(pointFeature);
|
|
376
381
|
return pointFeature;
|
|
377
382
|
})
|
|
378
383
|
.catch((error) => {
|
|
@@ -381,10 +386,7 @@ class RoutingControl extends ControlCommon {
|
|
|
381
386
|
return;
|
|
382
387
|
}
|
|
383
388
|
// Dispatch error event and execute error function
|
|
384
|
-
this.dispatchEvent(
|
|
385
|
-
type: 'error',
|
|
386
|
-
target: this,
|
|
387
|
-
});
|
|
389
|
+
this.dispatchEvent(new BaseEvent('error'));
|
|
388
390
|
this.onRouteError(error, this);
|
|
389
391
|
this.loading = false;
|
|
390
392
|
});
|
|
@@ -394,10 +396,10 @@ class RoutingControl extends ControlCommon {
|
|
|
394
396
|
//
|
|
395
397
|
// 47.37811,8.53935 a position 47.37811, 8.53935
|
|
396
398
|
if (this.useRawViaPoints && REGEX_VIA_POINT_COORD.test(viaPoint)) {
|
|
397
|
-
const [lat, lon] = REGEX_VIA_POINT_COORD.exec(viaPoint);
|
|
398
|
-
const coordinates = fromLonLat([parseFloat(lon), parseFloat(lat)], this.map.getView().getProjection());
|
|
399
|
+
const [lat, lon] = REGEX_VIA_POINT_COORD.exec(viaPoint) || [];
|
|
400
|
+
const coordinates = fromLonLat([parseFloat(lon), parseFloat(lat)], (_d = this.map) === null || _d === void 0 ? void 0 : _d.getView().getProjection());
|
|
399
401
|
pointFeature.setGeometry(new Point(coordinates));
|
|
400
|
-
this.routingLayer.olLayer.getSource().addFeature(pointFeature);
|
|
402
|
+
(_g = (_f = (_e = this.routingLayer) === null || _e === void 0 ? void 0 : _e.olLayer) === null || _f === void 0 ? void 0 : _f.getSource()) === null || _g === void 0 ? void 0 : _g.addFeature(pointFeature);
|
|
401
403
|
return Promise.resolve(pointFeature);
|
|
402
404
|
}
|
|
403
405
|
// Only when this.useRawViaPoints is true.
|
|
@@ -408,31 +410,29 @@ class RoutingControl extends ControlCommon {
|
|
|
408
410
|
// @47.37811,8.53935 a station at position 47.37811, 8.53935
|
|
409
411
|
// @47.37811,8.53935$4 track 4 in a station at position 47.37811, 8.53935
|
|
410
412
|
// zürich hb@47.37811,8.53935$8 track 8 in station "Zürich HB" at position 47.37811, 8.53935
|
|
411
|
-
const [, stationName, , lat, lon, , track] = REGEX_VIA_POINT.exec(viaPoint);
|
|
413
|
+
const [, stationName, , lat, lon, , track] = REGEX_VIA_POINT.exec(viaPoint) || [];
|
|
412
414
|
if (lon && lat) {
|
|
413
|
-
const coordinates = fromLonLat([parseFloat(lon), parseFloat(lat)], this.map.getView().getProjection());
|
|
415
|
+
const coordinates = fromLonLat([parseFloat(lon), parseFloat(lat)], (_h = this.map) === null || _h === void 0 ? void 0 : _h.getView().getProjection());
|
|
414
416
|
pointFeature.set('viaPointTrack', track);
|
|
415
417
|
pointFeature.setGeometry(new Point(coordinates));
|
|
416
|
-
this.routingLayer.olLayer.getSource().addFeature(pointFeature);
|
|
418
|
+
(_l = (_k = (_j = this.routingLayer) === null || _j === void 0 ? void 0 : _j.olLayer) === null || _k === void 0 ? void 0 : _k.getSource()) === null || _l === void 0 ? void 0 : _l.addFeature(pointFeature);
|
|
417
419
|
return Promise.resolve(pointFeature);
|
|
418
420
|
}
|
|
419
421
|
if (stationName) {
|
|
420
422
|
return fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${stationName}&limit=1`, { signal: abortController.signal })
|
|
421
423
|
.then((res) => res.json())
|
|
422
424
|
.then((stationData) => {
|
|
425
|
+
var _a, _b, _c;
|
|
423
426
|
const { coordinates } = stationData.features[0].geometry;
|
|
424
427
|
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
425
428
|
pointFeature.set('viaPointTrack', track);
|
|
426
429
|
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
427
|
-
this.routingLayer.olLayer.getSource().addFeature(pointFeature);
|
|
430
|
+
(_c = (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.addFeature(pointFeature);
|
|
428
431
|
return pointFeature;
|
|
429
432
|
})
|
|
430
433
|
.catch((error) => {
|
|
431
434
|
// Dispatch error event and execute error function
|
|
432
|
-
this.dispatchEvent(
|
|
433
|
-
type: 'error',
|
|
434
|
-
target: this,
|
|
435
|
-
});
|
|
435
|
+
this.dispatchEvent(new BaseEvent('error'));
|
|
436
436
|
this.onRouteError(error, this);
|
|
437
437
|
this.loading = false;
|
|
438
438
|
return null;
|
|
@@ -446,8 +446,8 @@ class RoutingControl extends ControlCommon {
|
|
|
446
446
|
* If an existing viaPoint is clicked removes the clicked viaPoint.
|
|
447
447
|
* @private
|
|
448
448
|
*/
|
|
449
|
-
onMapClick(
|
|
450
|
-
const feats =
|
|
449
|
+
onMapClick(evt) {
|
|
450
|
+
const feats = evt.target.getFeaturesAtPixel(evt.pixel);
|
|
451
451
|
const viaPoint = feats.find((feat) => {
|
|
452
452
|
var _a;
|
|
453
453
|
return ((_a = feat.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === GeomType.POINT &&
|
|
@@ -458,7 +458,7 @@ class RoutingControl extends ControlCommon {
|
|
|
458
458
|
this.removeViaPoint(viaPoint.get('viaPointIdx'));
|
|
459
459
|
return;
|
|
460
460
|
}
|
|
461
|
-
this.addViaPoint(
|
|
461
|
+
this.addViaPoint(evt.coordinate);
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
464
464
|
* Used on start of the modify interaction. Stores relevant data
|
|
@@ -466,16 +466,19 @@ class RoutingControl extends ControlCommon {
|
|
|
466
466
|
* @private
|
|
467
467
|
*/
|
|
468
468
|
onModifyStart(evt) {
|
|
469
|
+
var _a;
|
|
469
470
|
// When modify start, we search the index of the segment that is modifying.
|
|
470
471
|
let segmentIndex = -1;
|
|
471
472
|
const route = evt.features
|
|
472
473
|
.getArray()
|
|
473
474
|
.find((feat) => { var _a; return ((_a = feat.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === GeomType.LINE_STRING; });
|
|
474
475
|
// Find the segment index that is being modified
|
|
475
|
-
if (route) {
|
|
476
|
+
if (route && route.getGeometry() && evt.mapBrowserEvent.coordinate) {
|
|
476
477
|
// We use a buff extent to fix floating issues , see https://github.com/openlayers/openlayers/issues/7130#issuecomment-535856422
|
|
477
|
-
const closestExtent = buffer(new Point(
|
|
478
|
-
|
|
478
|
+
const closestExtent = buffer(new Point(
|
|
479
|
+
// @ts-ignore
|
|
480
|
+
(_a = route.getGeometry()) === null || _a === void 0 ? void 0 : _a.getClosestPoint(evt.mapBrowserEvent.coordinate)).getExtent(), 0.001);
|
|
481
|
+
segmentIndex = this.segments.findIndex((segment) => { var _a; return (_a = segment.getGeometry()) === null || _a === void 0 ? void 0 : _a.intersectsExtent(closestExtent); });
|
|
479
482
|
}
|
|
480
483
|
// Find the viaPoint that is being modified
|
|
481
484
|
const viaPoint = (evt.features
|
|
@@ -498,7 +501,7 @@ class RoutingControl extends ControlCommon {
|
|
|
498
501
|
*/
|
|
499
502
|
onModifyEnd(evt) {
|
|
500
503
|
const coord = evt.mapBrowserEvent.coordinate;
|
|
501
|
-
const { oldRoute, viaPoint, segmentIndex } = this.initialRouteDrag;
|
|
504
|
+
const { oldRoute, viaPoint, segmentIndex } = this.initialRouteDrag || {};
|
|
502
505
|
// If viaPoint is being relocated overwrite the old viaPoint
|
|
503
506
|
if (viaPoint) {
|
|
504
507
|
return this.addViaPoint(coord, viaPoint.get('viaPointIdx'), 1);
|
|
@@ -512,7 +515,7 @@ class RoutingControl extends ControlCommon {
|
|
|
512
515
|
return Promise.reject(new Error('No segment found'));
|
|
513
516
|
}
|
|
514
517
|
// Insert new viaPoint at the modified segment index + 1
|
|
515
|
-
return this.addViaPoint(coord, segmentIndex + 1);
|
|
518
|
+
return this.addViaPoint(coord, (segmentIndex || 0) + 1);
|
|
516
519
|
}
|
|
517
520
|
/**
|
|
518
521
|
* Define a default element.
|
|
@@ -536,15 +539,16 @@ class RoutingControl extends ControlCommon {
|
|
|
536
539
|
* @private
|
|
537
540
|
*/
|
|
538
541
|
createModifyInteraction() {
|
|
542
|
+
var _a, _b, _c;
|
|
539
543
|
/**
|
|
540
544
|
* @type {ol.interaction.Modify}
|
|
541
545
|
* @private
|
|
542
546
|
*/
|
|
543
547
|
// Define and add modify interaction
|
|
544
548
|
this.modifyInteraction = new Modify({
|
|
545
|
-
source: this.routingLayer.olLayer.getSource(),
|
|
549
|
+
source: ((_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) || undefined,
|
|
546
550
|
pixelTolerance: 4,
|
|
547
|
-
hitDetection: this.routingLayer.olLayer,
|
|
551
|
+
hitDetection: (_c = this.routingLayer) === null || _c === void 0 ? void 0 : _c.olLayer,
|
|
548
552
|
deleteCondition: (e) => {
|
|
549
553
|
const feats = e.target.getFeaturesAtPixel(e.pixel, {
|
|
550
554
|
hitTolerance: 5,
|
|
@@ -571,21 +575,25 @@ class RoutingControl extends ControlCommon {
|
|
|
571
575
|
* @private
|
|
572
576
|
*/
|
|
573
577
|
addListeners() {
|
|
578
|
+
var _a;
|
|
574
579
|
if (!this.modify) {
|
|
575
580
|
return;
|
|
576
581
|
}
|
|
577
582
|
this.removeListeners();
|
|
578
583
|
/** @ignore */
|
|
579
|
-
this.onMapClickKey = this.map.on('singleclick', this.onMapClick);
|
|
584
|
+
this.onMapClickKey = (_a = this.map) === null || _a === void 0 ? void 0 : _a.on('singleclick', this.onMapClick);
|
|
580
585
|
}
|
|
581
586
|
/**
|
|
582
587
|
* Remove click listener from map.
|
|
583
588
|
* @private
|
|
584
589
|
*/
|
|
585
590
|
removeListeners() {
|
|
586
|
-
|
|
591
|
+
if (this.onMapClickKey) {
|
|
592
|
+
unByKey(this.onMapClickKey);
|
|
593
|
+
}
|
|
587
594
|
}
|
|
588
595
|
activate() {
|
|
596
|
+
var _a, _b;
|
|
589
597
|
super.activate();
|
|
590
598
|
if (this.map) {
|
|
591
599
|
/** @ignore */
|
|
@@ -595,24 +603,26 @@ class RoutingControl extends ControlCommon {
|
|
|
595
603
|
/** @ignore */
|
|
596
604
|
this.graphsResolutions = RoutingControl.getGraphsResolutions(this.graphs, this.map);
|
|
597
605
|
// Clean the modifyInteraction if present
|
|
598
|
-
|
|
606
|
+
if (this.modifyInteraction) {
|
|
607
|
+
this.map.removeInteraction(this.modifyInteraction);
|
|
608
|
+
}
|
|
599
609
|
// Add modify interaction, RoutingLayer and listeners
|
|
600
|
-
this.routingLayer.attachToMap(this.map);
|
|
601
|
-
|
|
602
|
-
|
|
610
|
+
(_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.attachToMap(this.map);
|
|
611
|
+
if (this.modifyInteraction) {
|
|
612
|
+
this.map.addInteraction(this.modifyInteraction);
|
|
613
|
+
}
|
|
614
|
+
(_b = this.modifyInteraction) === null || _b === void 0 ? void 0 : _b.setActive(this.modify);
|
|
603
615
|
this.addListeners();
|
|
604
616
|
}
|
|
605
|
-
else {
|
|
606
|
-
// fall back to some default values if map is not available
|
|
607
|
-
this.format = new GeoJSON({ featureProjection: 'EPSG:3857' });
|
|
608
|
-
this.graphsResolutions = this.graphs;
|
|
609
|
-
}
|
|
610
617
|
}
|
|
611
618
|
deactivate() {
|
|
619
|
+
var _a;
|
|
612
620
|
if (this.map) {
|
|
613
621
|
// Remove modify interaction, RoutingLayer, listeners and viaPoints
|
|
614
|
-
this.routingLayer.detachFromMap(
|
|
615
|
-
|
|
622
|
+
(_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.detachFromMap();
|
|
623
|
+
if (this.modifyInteraction) {
|
|
624
|
+
this.map.removeInteraction(this.modifyInteraction);
|
|
625
|
+
}
|
|
616
626
|
this.removeListeners();
|
|
617
627
|
this.reset();
|
|
618
628
|
}
|
package/ol/layers/Layer.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { EventsKey } from 'ol/events';
|
|
|
3
3
|
import LayerGroup from 'ol/layer/Group';
|
|
4
4
|
import OlLayer from 'ol/layer/Layer';
|
|
5
5
|
import LayerCommon from '../../common/layers/LayerCommon';
|
|
6
|
+
import type { LayerCommonOptions } from '../../common/layers/LayerCommon';
|
|
6
7
|
import type { UserInteractionCallback } from '../../types';
|
|
7
8
|
export declare type OlLayerOptions = LayerCommonOptions & {
|
|
8
|
-
olLayer
|
|
9
|
+
olLayer?: OlLayer;
|
|
9
10
|
};
|
|
10
11
|
declare const Layer_base: typeof LayerCommon;
|
|
11
12
|
/**
|
|
@@ -24,7 +25,7 @@ declare const Layer_base: typeof LayerCommon;
|
|
|
24
25
|
* @extends {LayerCommon}
|
|
25
26
|
*/
|
|
26
27
|
declare class Layer extends Layer_base {
|
|
27
|
-
olLayer?: OlLayer;
|
|
28
|
+
olLayer?: OlLayer | LayerGroup;
|
|
28
29
|
olListenersKeys: EventsKey[];
|
|
29
30
|
options: OlLayerOptions;
|
|
30
31
|
visible: boolean;
|
package/ol/layers/Layer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,oBAAY,cAAc,GAAG,kBAAkB,GAAG;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAEF;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE/B,eAAe,EAAG,SAAS,EAAE,CAAC;IAI9B,OAAO,EAAG,cAAc,CAAC;IAEzB,OAAO,EAAG,OAAO,CAAC;IAElB,UAAU,EAAG,MAAM,EAAE,CAAC;IAEtB,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,sBAAsB,EAAG,SAAS,CAAC;IAEnC,sBAAsB,EAAG,SAAS,CAAC;IAInC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;;;;;;;;;OAWG;gBACS,OAAO,EAAE,cAAc;IAQnC;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,cAAc;IAUxC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG;IA4DpB;;OAEG;IACH,aAAa;IAcb,wBAAwB;IA2BxB,0BAA0B;IAI1B;;;OAGG;IACH,sBAAsB;IAQtB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,cAAc;CAGjC;AACD,eAAe,KAAK,CAAC"}
|
package/ol/layers/Layer.js
CHANGED
|
@@ -94,8 +94,10 @@ class Layer extends userInteractionsMixin(LayerCommon) {
|
|
|
94
94
|
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.setAttributions(attributions);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
+
// @ts-ignore
|
|
97
98
|
}
|
|
98
99
|
else if (this.olLayer.getSource) {
|
|
100
|
+
// @ts-ignore
|
|
99
101
|
(_d = this.olLayer.getSource()) === null || _d === void 0 ? void 0 : _d.setAttributions(attributions);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapGlLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapGlLayer.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"MapGlLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapGlLayer.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhD,oBAAY,iBAAiB,GAAG,cAAc,GAAG;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,UAAW,SAAQ,KAAK;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAG,MAAM,CAAC;IAEpB,MAAM,EAAG,OAAO,CAAC;IAEjB,MAAM,EAAG,OAAO,CAAC;IAEjB,OAAO,EAAG,iBAAiB,CAAC;gBAEhB,OAAO,EAAE,iBAAiB;IAmCtC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAkBtB;;OAEG;IACH,aAAa;IAab;;;OAGG;IACH,SAAS;IAuET;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW;IAStE;;;;;OAKG;IACH,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,2BAA2B,CAAC;IAqDvC;;;OAGG;IAEH,gBAAgB,IAAI,cAAc;IAOlC;;;;OAIG;IAEH,iBAAiB,IAAI,iBAAiB;CAMvC;AAED,eAAe,UAAU,CAAC"}
|
package/ol/layers/MapGlLayer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { toLonLat } from 'ol/proj';
|
|
|
3
3
|
import OlLayer from 'ol/layer/Layer';
|
|
4
4
|
import Source from 'ol/source/Source';
|
|
5
5
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
6
|
+
import BaseEvent from 'ol/events/Event';
|
|
6
7
|
import { getUrlWithParams, getMapboxMapCopyrights } from '../../common/utils';
|
|
7
8
|
import Layer from './Layer';
|
|
8
9
|
/**
|
|
@@ -122,11 +123,7 @@ class MapGlLayer extends Layer {
|
|
|
122
123
|
* @type {boolean}
|
|
123
124
|
*/
|
|
124
125
|
this.loaded = true;
|
|
125
|
-
|
|
126
|
-
this.dispatchEvent({
|
|
127
|
-
type: 'load',
|
|
128
|
-
target: this,
|
|
129
|
-
});
|
|
126
|
+
this.dispatchEvent(new BaseEvent('load'));
|
|
130
127
|
});
|
|
131
128
|
this.mbMap.on('idle', this.updateAttribution);
|
|
132
129
|
}
|
|
@@ -139,6 +136,7 @@ class MapGlLayer extends Layer {
|
|
|
139
136
|
const newAttributions = getMapboxMapCopyrights(evt.target) || [];
|
|
140
137
|
if (((_a = this.copyrights) === null || _a === void 0 ? void 0 : _a.toString()) !== newAttributions.toString()) {
|
|
141
138
|
this.copyrights = newAttributions;
|
|
139
|
+
// @ts-ignore
|
|
142
140
|
(_c = (_b = this.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setAttributions(newAttributions);
|
|
143
141
|
}
|
|
144
142
|
}
|
|
@@ -38,7 +38,7 @@ export default class MapboxLayer extends MapGlLayer {
|
|
|
38
38
|
* @private
|
|
39
39
|
*/
|
|
40
40
|
loadMbMap(): void;
|
|
41
|
-
getOlLayerRender():
|
|
41
|
+
getOlLayerRender(): import("ol/layer/Layer").RenderFunction;
|
|
42
42
|
getMapboxMapClass(): typeof Map;
|
|
43
43
|
/**
|
|
44
44
|
* Create a copy of the MapboxLayer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapboxLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapboxLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,WAAW,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,IAAI,CAAC;KACb,CAAC;IAEF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAsBtB;;;OAGG;IACH,SAAS;
|
|
1
|
+
{"version":3,"file":"MapboxLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapboxLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,WAAW,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,IAAI,CAAC;KACb,CAAC;IAEF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAsBtB;;;OAGG;IACH,SAAS;IAqDT,gBAAgB;IAKhB,iBAAiB;IAIjB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,iBAAiB;CAGpC"}
|
package/ol/layers/MapboxLayer.js
CHANGED
|
@@ -76,6 +76,7 @@ export default class MapboxLayer extends MapGlLayer {
|
|
|
76
76
|
this.mbMap.resize();
|
|
77
77
|
/** @ignore */
|
|
78
78
|
this.copyrights = getMapboxMapCopyrights(this.mbMap) || [];
|
|
79
|
+
// @ts-ignore
|
|
79
80
|
(_b = (_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.setAttributions(this.copyrights);
|
|
80
81
|
});
|
|
81
82
|
const mapboxCanvas = this.mbMap.getCanvas();
|
|
@@ -98,8 +98,10 @@ class MapboxStyleLayer extends Layer {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
if (!this.styleLayersFilter && this.styleLayers) {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
this.styleLayersFilter = (styleLayer) => {
|
|
102
|
+
var _a;
|
|
103
|
+
return !!((_a = this.styleLayers) === null || _a === void 0 ? void 0 : _a.find((sl) => styleLayer.id === sl.id));
|
|
104
|
+
};
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
/**
|
|
@@ -15,7 +15,8 @@ import MapGlLayer, { MapGlLayerOptions } from './MapGlLayer';
|
|
|
15
15
|
* @extends {Layer}
|
|
16
16
|
*/
|
|
17
17
|
export default class MaplibreLayer extends MapGlLayer {
|
|
18
|
-
|
|
18
|
+
mbMap?: maplibregl.Map;
|
|
19
|
+
getOlLayerRender(): import("ol/layer/Layer").RenderFunction;
|
|
19
20
|
getMapboxMapClass(): typeof Map;
|
|
20
21
|
/**
|
|
21
22
|
* Create a copy of the MapboxLayer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaplibreLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MaplibreLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,gBAAgB;IAKhB,iBAAiB;IAIjB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,iBAAiB;CAGpC"}
|
|
1
|
+
{"version":3,"file":"MaplibreLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MaplibreLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;IAEvB,gBAAgB;IAKhB,iBAAiB;IAIjB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,iBAAiB;CAGpC"}
|