mobility-toolbox-js 3.0.0-beta.5 → 3.0.0-beta.7
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/mbt.js +2 -48
- package/mbt.js.map +2 -2
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +3 -3
- package/ol/layers/MapGlLayer.js +1 -1
- package/ol/layers/MaplibreStyleLayer.js +1 -1
- package/ol/mixins/PropertiesLayerMixin.js +0 -60
- package/package.json +1 -1
package/ol/layers/MapGlLayer.js
CHANGED
|
@@ -56,7 +56,7 @@ class MapGlLayer extends MobilityLayerMixin(Layer) {
|
|
|
56
56
|
this.loadMbMap();
|
|
57
57
|
const updateMbMapDebounced = debounce(this.updateMbMap.bind(this), 150);
|
|
58
58
|
this.olListenersKeys.push(this.on('propertychange', (evt) => {
|
|
59
|
-
if (/(apiKey|apiKeyName|url|style
|
|
59
|
+
if (/(apiKey|apiKeyName|url|style)/.test(evt.key)) {
|
|
60
60
|
updateMbMapDebounced();
|
|
61
61
|
}
|
|
62
62
|
}));
|
|
@@ -165,7 +165,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
165
165
|
// the style. Maplibre take care of the application of style changes.
|
|
166
166
|
this.applyLayoutVisibility(evt);
|
|
167
167
|
}), this.on('propertychange', (evt) => {
|
|
168
|
-
if (/(sources|layers|layersFilter|maplibreLayer|beforeId
|
|
168
|
+
if (/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(evt.key)) {
|
|
169
169
|
this.detachFromMap();
|
|
170
170
|
this.attachToMap(map);
|
|
171
171
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import BaseEvent from 'ol/events/Event';
|
|
2
1
|
import { getUid } from 'ol';
|
|
3
2
|
import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
|
|
4
3
|
/**
|
|
@@ -87,25 +86,6 @@ function PropertiesLayerMixin(Base) {
|
|
|
87
86
|
if (evt.key === 'children') {
|
|
88
87
|
this.onChildrenChange(evt.oldValue);
|
|
89
88
|
}
|
|
90
|
-
}),
|
|
91
|
-
// Manage group visiblity
|
|
92
|
-
this.on('change:visible', () => {
|
|
93
|
-
this.onVisibleChange();
|
|
94
|
-
}),
|
|
95
|
-
// Listen for group visiblity change
|
|
96
|
-
// if a layer from a group is newly visible we hide the others.
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
this.on(`change:visible:group`, (evt) => {
|
|
99
|
-
// We hide layer of the same group
|
|
100
|
-
if (this.group === evt.target.group &&
|
|
101
|
-
this !== evt.target &&
|
|
102
|
-
this.visible) {
|
|
103
|
-
this.visible = false;
|
|
104
|
-
// Propagate event to parent
|
|
105
|
-
}
|
|
106
|
-
else if (this.children) {
|
|
107
|
-
this.children.forEach((child) => child.dispatchEvent(evt));
|
|
108
|
-
}
|
|
109
89
|
}));
|
|
110
90
|
this.options = options;
|
|
111
91
|
this.children = options.children || []; // Trigger the on children change event
|
|
@@ -129,46 +109,6 @@ function PropertiesLayerMixin(Base) {
|
|
|
129
109
|
child.set('parent', this);
|
|
130
110
|
});
|
|
131
111
|
}
|
|
132
|
-
/** @private */
|
|
133
|
-
onVisibleChange() {
|
|
134
|
-
const parent = this.get('parent');
|
|
135
|
-
const children = this.get('children') || [];
|
|
136
|
-
if (this.getVisible()) {
|
|
137
|
-
const group = this.get('group');
|
|
138
|
-
// We make the parent visible
|
|
139
|
-
if (parent) {
|
|
140
|
-
parent.setVisible(true);
|
|
141
|
-
}
|
|
142
|
-
// If children doesn't contain any visible layers, we display all children.
|
|
143
|
-
if (children && !children.some((child) => child.getVisible())) {
|
|
144
|
-
children.forEach((child) => {
|
|
145
|
-
child.setVisible(true);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
// Warn the same group that a new layer is visible
|
|
149
|
-
if (parent && group) {
|
|
150
|
-
// We search for the higher parent then it will dispatch to all the tree.
|
|
151
|
-
let higherParent = parent;
|
|
152
|
-
while (higherParent.get('parent')) {
|
|
153
|
-
higherParent = higherParent.get('parent');
|
|
154
|
-
}
|
|
155
|
-
const evt = new BaseEvent(`change:visible:group`);
|
|
156
|
-
evt.target = this;
|
|
157
|
-
higherParent.dispatchEvent(evt);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
// We hide all the children
|
|
162
|
-
children.forEach((child) => {
|
|
163
|
-
child.setVisible(false);
|
|
164
|
-
});
|
|
165
|
-
// If the parent has no more visible child we also hide it.
|
|
166
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.getVisible()) &&
|
|
167
|
-
!(parent === null || parent === void 0 ? void 0 : parent.get('children').find((child) => child.getVisible()))) {
|
|
168
|
-
parent.setVisible(false);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
112
|
/**
|
|
173
113
|
* Initialize the layer with the map passed in parameters.
|
|
174
114
|
*
|
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.7",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"exports": {
|