@geops/rvf-mobility-web-component 0.1.69 → 0.1.71
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/CHANGELOG.md +15 -0
- package/index.js +43 -43
- package/package.json +1 -1
- package/src/FeaturesInfosListener/FeaturesInfosListener.tsx +1 -5
- package/src/MapsetLayer/MapsetLayer.tsx +13 -5
- package/src/RealtimeLayer/RealtimeLayer.tsx +1 -0
- package/src/SingleClickListener/SingleClickListener.tsx +30 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@geops/rvf-mobility-web-component",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
4
|
"description": "Web components for rvf in the domains of mobility and logistics.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.71",
|
|
6
6
|
"homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
@@ -33,15 +33,11 @@ function FeaturesInfosListener() {
|
|
|
33
33
|
return info.layer === realtimeLayer;
|
|
34
34
|
})?.features || [];
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const [stationFeature] =
|
|
37
37
|
featuresInfos?.find((info) => {
|
|
38
38
|
return info.layer === stationsLayer;
|
|
39
39
|
})?.features || [];
|
|
40
40
|
|
|
41
|
-
const [stationFeature] = stationsFeatures.filter((feat) => {
|
|
42
|
-
return feat.get("tralis_network")?.includes(tenant);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
41
|
const features =
|
|
46
42
|
featuresInfos?.flatMap((info) => {
|
|
47
43
|
return info.features;
|
|
@@ -51,11 +51,19 @@ function MapsetLayer(props?: Partial<MapsetLayerOptions>) {
|
|
|
51
51
|
bbox = transformExtent(bbox, "EPSG:3857", "EPSG:4326");
|
|
52
52
|
}
|
|
53
53
|
} else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
// we have to wait that the map is well sized to get the extent
|
|
55
|
+
// It triggers an erro in FF without this
|
|
56
|
+
if (
|
|
57
|
+
map.getView()?.getCenter() &&
|
|
58
|
+
map.getSize()[0] > 0 &&
|
|
59
|
+
map.getSize()[1] > 0
|
|
60
|
+
) {
|
|
61
|
+
bbox = transformExtent(
|
|
62
|
+
map.getView()?.calculateExtent(),
|
|
63
|
+
"EPSG:3857",
|
|
64
|
+
"EPSG:4326",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
59
67
|
}
|
|
60
68
|
return new MtbMapsetLayer({
|
|
61
69
|
apiKey: apikey,
|
|
@@ -243,6 +243,7 @@ function RealtimeLayer(props: Partial<RealtimeLayerOptions>) {
|
|
|
243
243
|
setStopSequence(null);
|
|
244
244
|
if (trainId && layer) {
|
|
245
245
|
layer.api?.unsubscribeStopSequence(trainId);
|
|
246
|
+
layer.api?.unsubscribeFullTrajectory(layer.selectedVehicleId);
|
|
246
247
|
layer.selectedVehicleId = null;
|
|
247
248
|
layer.vectorLayer.getSource().clear();
|
|
248
249
|
}
|
|
@@ -20,8 +20,14 @@ function SingleClickListener({
|
|
|
20
20
|
debounceTimeout = 0,
|
|
21
21
|
hover = true,
|
|
22
22
|
}: SingleClickListenerProps) {
|
|
23
|
-
const {
|
|
24
|
-
|
|
23
|
+
const {
|
|
24
|
+
map,
|
|
25
|
+
queryablelayers,
|
|
26
|
+
setFeaturesInfos,
|
|
27
|
+
setFeaturesInfosHovered,
|
|
28
|
+
stationsLayer,
|
|
29
|
+
tenant,
|
|
30
|
+
} = useMapContext();
|
|
25
31
|
|
|
26
32
|
const getFeaturesInfosAtEvt = useCallback(
|
|
27
33
|
async (evt: MapBrowserEvent<PointerEvent>) => {
|
|
@@ -34,9 +40,30 @@ function SingleClickListener({
|
|
|
34
40
|
5,
|
|
35
41
|
true,
|
|
36
42
|
);
|
|
43
|
+
|
|
44
|
+
// Filter the features clicked in the stations layer by the tenant
|
|
45
|
+
if (stationsLayer) {
|
|
46
|
+
// Clean the features infos stations clicked
|
|
47
|
+
const featuresInfoStations = featuresInfos?.find((info) => {
|
|
48
|
+
return info.layer === stationsLayer;
|
|
49
|
+
});
|
|
50
|
+
const stationsFeatures = featuresInfoStations?.features || [];
|
|
51
|
+
|
|
52
|
+
const [stationFeature] = stationsFeatures.filter((feat) => {
|
|
53
|
+
return feat.get("tralis_network")?.includes(tenant);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Replace the features clicked in the stations layer by the filtered one
|
|
57
|
+
if (featuresInfoStations) {
|
|
58
|
+
featuresInfoStations.features = stationFeature
|
|
59
|
+
? [stationFeature]
|
|
60
|
+
: [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
37
64
|
return featuresInfos;
|
|
38
65
|
},
|
|
39
|
-
[queryablelayers],
|
|
66
|
+
[queryablelayers, stationsLayer, tenant],
|
|
40
67
|
);
|
|
41
68
|
|
|
42
69
|
const onPointerMove = useCallback(
|