mobility-toolbox-js 3.0.0-beta.36 → 3.0.0-beta.37
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 +11 -3
- package/mbt.js +235 -114
- package/mbt.js.map +3 -3
- package/mbt.min.js +15 -15
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.d.ts +1 -1
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/layers/MaplibreLayer.js +7 -4
- package/ol/styles/routingStyle.js +11 -3
- package/package.json +13 -14
|
@@ -27,7 +27,7 @@ export type RoutingControlOptions = {
|
|
|
27
27
|
style?: StyleLike;
|
|
28
28
|
useRawViaPoints?: boolean;
|
|
29
29
|
} & Options;
|
|
30
|
-
export type
|
|
30
|
+
export type AbortControllersByGraph = Record<string, AbortController>;
|
|
31
31
|
/**
|
|
32
32
|
* This OpenLayers control allows the user to add and modifiy via points to
|
|
33
33
|
* a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
@@ -250,7 +250,7 @@ class RoutingControl extends Control {
|
|
|
250
250
|
*/
|
|
251
251
|
// Define and add modify interaction
|
|
252
252
|
this.modifyInteraction = new Modify({
|
|
253
|
-
// hitDetection: this.routingLayer, //
|
|
253
|
+
// hitDetection: this.routingLayer, // TODO: wait for ol, fixed in https://github.com/openlayers/openlayers/pull/16393
|
|
254
254
|
deleteCondition: (e) => {
|
|
255
255
|
var _a;
|
|
256
256
|
const feats = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.getFeaturesAtPixel(e.pixel, {
|
|
@@ -294,7 +294,7 @@ class RoutingControl extends Control {
|
|
|
294
294
|
var _a, _b;
|
|
295
295
|
/* Calls RoutingAPI to draw a route using the viaPoints array */
|
|
296
296
|
this.abortRequests();
|
|
297
|
-
(_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(
|
|
297
|
+
(_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
298
298
|
if (!this.viaPoints.length) {
|
|
299
299
|
return null;
|
|
300
300
|
}
|
|
@@ -71,6 +71,9 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
71
71
|
newOptions.mapLibreOptions.style = buildStyleUrl(newOptions.url, newOptions.style, newOptions.apiKey, newOptions.apiKeyName);
|
|
72
72
|
}
|
|
73
73
|
super(newOptions);
|
|
74
|
+
// We save the options to be able to clone the layer.
|
|
75
|
+
// and to see if the style is defined by the maplibreOptions given by the user.
|
|
76
|
+
this.set('options', options);
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
76
79
|
* Initialize the layer and listen to feature clicks.
|
|
@@ -105,7 +108,7 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
105
108
|
return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
106
109
|
}
|
|
107
110
|
getStyle() {
|
|
108
|
-
var _a;
|
|
111
|
+
var _a, _b;
|
|
109
112
|
// If the style is a complete style object, use it directly.
|
|
110
113
|
if (this.style &&
|
|
111
114
|
typeof this.style === 'object' &&
|
|
@@ -117,9 +120,9 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
117
120
|
if (this.url.includes('style.json')) {
|
|
118
121
|
return this.url;
|
|
119
122
|
}
|
|
120
|
-
// If the
|
|
121
|
-
if ((_a = this.get('
|
|
122
|
-
return this.get('
|
|
123
|
+
// If the user has defined the style by the maplibreOptions, we use it directly.
|
|
124
|
+
if ((_b = (_a = this.get('options')) === null || _a === void 0 ? void 0 : _a.mapLibreOptions) === null || _b === void 0 ? void 0 : _b.style) {
|
|
125
|
+
return this.get('options').mapLibreOptions.style;
|
|
123
126
|
}
|
|
124
127
|
/// Otherwise build the complete style url.
|
|
125
128
|
return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
|
|
@@ -32,16 +32,24 @@ const dashedRedLine = new Style({
|
|
|
32
32
|
}),
|
|
33
33
|
});
|
|
34
34
|
const routingStyle = (feature, resolution) => {
|
|
35
|
+
var _a;
|
|
35
36
|
const minResolution = feature.get('minResolution');
|
|
36
37
|
const maxResolution = feature.get('maxResolution');
|
|
37
38
|
const inRange = resolution <= minResolution && resolution > maxResolution;
|
|
38
39
|
if (minResolution && maxResolution && !inRange) {
|
|
39
40
|
return [];
|
|
40
41
|
}
|
|
42
|
+
const zIndex = ((_a = feature === null || feature === void 0 ? void 0 : feature.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === 'Point' ? 100 : 0;
|
|
43
|
+
let styles = [blackBorder, redLine];
|
|
41
44
|
const mot = feature.get('mot');
|
|
42
|
-
if (mot
|
|
43
|
-
|
|
45
|
+
if (mot === 'foot') {
|
|
46
|
+
styles = [dashedRedLine];
|
|
44
47
|
}
|
|
45
|
-
|
|
48
|
+
styles = styles.map((style) => {
|
|
49
|
+
const tmp = style.clone();
|
|
50
|
+
tmp.setZIndex(zIndex);
|
|
51
|
+
return tmp;
|
|
52
|
+
});
|
|
53
|
+
return styles;
|
|
46
54
|
};
|
|
47
55
|
export default routingStyle;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mobility-toolbox-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
|
|
5
|
-
"version": "3.0.0-beta.
|
|
5
|
+
"version": "3.0.0-beta.37",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@babel/preset-env": "^7.26.0",
|
|
28
28
|
"@babel/preset-typescript": "^7.26.0",
|
|
29
|
-
"@commitlint/cli": "19.
|
|
30
|
-
"@commitlint/config-conventional": "19.
|
|
29
|
+
"@commitlint/cli": "19.6.0",
|
|
30
|
+
"@commitlint/config-conventional": "19.6.0",
|
|
31
31
|
"@geops/eslint-config-react": "^1.2.0",
|
|
32
32
|
"@types/geojson": "7946.0.14",
|
|
33
33
|
"@types/lodash": "^4.17.13",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@types/offscreencanvas": "2019.7.3",
|
|
38
38
|
"@types/topojson": "3.2.6",
|
|
39
39
|
"@types/uuid": "10.0.0",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
41
|
-
"@typescript-eslint/parser": "8.
|
|
42
|
-
"cypress": "13.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "8.15.0",
|
|
41
|
+
"@typescript-eslint/parser": "8.15.0",
|
|
42
|
+
"cypress": "13.16.0",
|
|
43
43
|
"esbuild": "0.24.0",
|
|
44
44
|
"esdoc": "1.1.0",
|
|
45
45
|
"esdoc-ecmascript-proposal-plugin": "1.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"eslint-plugin-prettier": "5.2.1",
|
|
57
57
|
"eslint-plugin-react": "7.37.2",
|
|
58
58
|
"fixpack": "4.0.0",
|
|
59
|
-
"husky": "9.1.
|
|
59
|
+
"husky": "9.1.7",
|
|
60
60
|
"is-ci": "3.0.1",
|
|
61
61
|
"jest": "29.7.0",
|
|
62
62
|
"jest-canvas-mock": "2.5.2",
|
|
@@ -80,9 +80,10 @@
|
|
|
80
80
|
"stylelint": "16.10.0",
|
|
81
81
|
"stylelint-config-recommended-scss": "14.1.0",
|
|
82
82
|
"stylelint-config-standard": "36.0.1",
|
|
83
|
-
"stylelint-scss": "6.
|
|
83
|
+
"stylelint-scss": "6.10.0",
|
|
84
84
|
"ts-jest": "^29.2.5",
|
|
85
|
-
"typescript": "5.6.3"
|
|
85
|
+
"typescript": "5.6.3",
|
|
86
|
+
"vite": "^5.4.11"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
89
|
"apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
|
|
@@ -95,9 +96,10 @@
|
|
|
95
96
|
"cy:test:chrome": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser chrome'",
|
|
96
97
|
"cy:test:edge": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser edge'",
|
|
97
98
|
"cy:test:firefox": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser firefox'",
|
|
98
|
-
"dev": "
|
|
99
|
-
"dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
|
|
99
|
+
"dev": "vite",
|
|
100
100
|
"doc": "yarn build && yarn apidoc && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn build",
|
|
101
|
+
"doc:dev": "yarn clean && yarn build && yarn apidoc && yarn dev:examples",
|
|
102
|
+
"doc:dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
|
|
101
103
|
"esbuild": "yarn esbuild:all && yarn esbuild:iife",
|
|
102
104
|
"esbuild:all": "esbuild src/index.js src/**/*.js src/**/*.ts src/**/**/*.js src/**/**/*.ts --target=chrome100 --outdir=build/ --loader:.js=jsx",
|
|
103
105
|
"esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
|
|
@@ -105,9 +107,6 @@
|
|
|
105
107
|
"esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
|
|
106
108
|
"esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
|
|
107
109
|
"format": "prettier --write 'src/**/*.js' 'src/**/*.test.js' && eslint src/**/*.js src/**/*.test.js src/**/*.ts --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix --allow-empty-input",
|
|
108
|
-
"lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
|
|
109
|
-
"lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
|
|
110
|
-
"link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
|
|
111
110
|
"lint": "eslint src/**/*.js src/**/*.ts && stylelint src/**/*.css src/**/*.scss --allow-empty-input",
|
|
112
111
|
"prepare": "is-ci || husky",
|
|
113
112
|
"publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push origin HEAD && git push --tags ",
|