@geops/rvf-mobility-web-component 0.1.45 → 0.1.47-beta.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.
Files changed (195) hide show
  1. package/.prettierrc.js +3 -1
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +1 -1
  4. package/doc/package.json +4 -3
  5. package/doc/postcss.config.mjs +1 -1
  6. package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
  7. package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
  8. package/doc/src/app/components/WebComponentDoc.tsx +45 -56
  9. package/doc/src/app/geops-mobility/page.tsx +7 -2
  10. package/doc/src/app/geops-mobility-search/page.tsx +6 -2
  11. package/doc/src/app/globals.css +47 -27
  12. package/doc/src/app/layout.tsx +4 -2
  13. package/docutils.js +33 -17
  14. package/eslint.config.mjs +28 -34
  15. package/iframe.html +5624 -201
  16. package/index.html +108 -88
  17. package/index.js +2229 -1976
  18. package/input.css +21 -3
  19. package/package.json +37 -40
  20. package/scripts/build.mjs +2 -2
  21. package/scripts/dev.mjs +3 -3
  22. package/search.html +70 -23
  23. package/src/BaseLayer/BaseLayer.tsx +2 -1
  24. package/src/Copyright/Copyright.tsx +4 -2
  25. package/src/DebugDeparture/DebugDeparture.tsx +16 -12
  26. package/src/DebugStop/DebugStop.tsx +2 -2
  27. package/src/Departure/Departure.tsx +2 -3
  28. package/src/EmbedNavigation/DragPanWarning.ts +125 -0
  29. package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
  30. package/src/EmbedNavigation/index.js +1 -0
  31. package/src/EmbedNavigation/index.tsx +1 -0
  32. package/src/GeolocationButton/GeolocationButton.tsx +11 -35
  33. package/src/GeolocationButton/index.tsx +1 -1
  34. package/src/Map/Map.tsx +5 -3
  35. package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
  36. package/src/MapDispatchEvents/index.tsx +1 -0
  37. package/src/MobilityMap/MobilityMap.tsx +117 -162
  38. package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
  39. package/src/MobilityMap/MobilityMapAttributes.ts +243 -0
  40. package/src/MobilityMap/index.tsx +1 -0
  41. package/src/MobilitySearch/MobilitySearch.tsx +35 -0
  42. package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
  43. package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
  44. package/src/MobilitySearch/index.ts +2 -0
  45. package/src/NotificationLayer/NotificationLayer.tsx +27 -4
  46. package/src/Overlay/Overlay.tsx +24 -11
  47. package/src/Permalink/Permalink.tsx +77 -0
  48. package/src/Permalink/index.tsx +1 -0
  49. package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
  50. package/src/RouteDestination/RouteDestination.tsx +3 -3
  51. package/src/RouteIcon/RouteIcon.tsx +33 -25
  52. package/src/RouteIcon/index.tsx +1 -1
  53. package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
  54. package/src/RouteInfos/RouteInfos.tsx +7 -3
  55. package/src/RouteSchedule/RouteSchedule.tsx +3 -3
  56. package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
  57. package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
  58. package/src/RouteStop/RouteStop.tsx +8 -11
  59. package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
  60. package/src/RouteStopName/RouteStopName.tsx +2 -2
  61. package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
  62. package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
  63. package/src/RouteStopServices/RouteStopServices.tsx +2 -2
  64. package/src/RouteStopStation/RouteStopStation.tsx +8 -2
  65. package/src/RouteStopTime/RouteStopTime.tsx +2 -1
  66. package/src/RvfButton/RvfButton.tsx +14 -5
  67. package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
  68. package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
  69. package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
  70. package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
  71. package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
  72. package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +5 -5
  73. package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +164 -138
  74. package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +151 -109
  75. package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
  76. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
  77. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
  78. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
  79. package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
  80. package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
  81. package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
  82. package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
  83. package/src/RvfGeolocationButton/index.tsx +1 -0
  84. package/src/RvfIconButton/RvfIconButton.tsx +20 -9
  85. package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
  86. package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
  87. package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
  88. package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
  89. package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
  90. package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
  91. package/src/RvfLink/RvfLink.tsx +4 -3
  92. package/src/RvfMobilityMap/RvfMobilityMap.tsx +314 -322
  93. package/src/RvfModal/RvfModal.tsx +4 -3
  94. package/src/RvfOverlayContent/RvfOverlayContent.tsx +126 -0
  95. package/src/RvfOverlayContent/index.ts +0 -0
  96. package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
  97. package/src/RvfPermalink/RvfPermalink.tsx +2 -2
  98. package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
  99. package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
  100. package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
  101. package/src/RvfRouteIcon/index.tsx +1 -0
  102. package/src/RvfSearch/RvfSearch.tsx +4 -1
  103. package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
  104. package/src/RvfSearchButton/index.tsx +1 -0
  105. package/src/RvfSelect/RvfSelect.tsx +7 -5
  106. package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
  107. package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
  108. package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
  109. package/src/RvfShare/RvfShare.tsx +11 -10
  110. package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
  111. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
  112. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +46 -31
  113. package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
  114. package/src/RvfTopics/RvfTopics.tsx +6 -5
  115. package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
  116. package/src/ScaleLine/ScaleLine.tsx +5 -4
  117. package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
  118. package/src/ScrollableHandler/index.tsx +1 -1
  119. package/src/SingleClickListener/SingleClickListener.tsx +47 -4
  120. package/src/Station/Station.tsx +5 -5
  121. package/src/StationName/StationName.tsx +3 -3
  122. package/src/StationServices/StationServices.tsx +3 -3
  123. package/src/StationsLayer/StationsLayer.tsx +5 -4
  124. package/src/StopsSearch/StopsSearch.tsx +115 -84
  125. package/src/WindowMessageListener/WindowMessageListener.tsx +67 -0
  126. package/src/WindowMessageListener/index.tsx +1 -0
  127. package/src/icons/Airport/Airport.tsx +4 -4
  128. package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
  129. package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
  130. package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
  131. package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
  132. package/src/icons/Bathroom/Bathroom.tsx +1 -1
  133. package/src/icons/Copy/Copy.tsx +1 -1
  134. package/src/icons/Doc/Doc.tsx +1 -1
  135. package/src/icons/Email/Email.tsx +1 -1
  136. package/src/icons/FilePdf/FilePdf.tsx +1 -1
  137. package/src/icons/Geolocation/Geolocation.tsx +3 -5
  138. package/src/icons/Image/Image.tsx +1 -1
  139. package/src/icons/Menu/Menu.tsx +1 -1
  140. package/src/icons/Minus/Minus.tsx +1 -1
  141. package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
  142. package/src/icons/Plus/Plus.tsx +1 -1
  143. package/src/icons/Police/Police.tsx +3 -3
  144. package/src/icons/Share/Share.tsx +1 -1
  145. package/src/icons/Stack/Stack.tsx +1 -1
  146. package/src/icons/Tracking/Tracking.tsx +29 -0
  147. package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
  148. package/src/icons/Tracking/index.tsx +1 -0
  149. package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
  150. package/src/icons/WheelChair/WheelChair.tsx +1 -1
  151. package/src/index.tsx +8 -46
  152. package/src/indexDoc.ts +13 -0
  153. package/src/ui/Button/Button.tsx +57 -0
  154. package/src/ui/Button/index.tsx +1 -0
  155. package/src/ui/IconButton/IconButton.tsx +44 -0
  156. package/src/ui/IconButton/index.tsx +1 -0
  157. package/src/utils/MobilityEvent.ts +4 -3
  158. package/src/utils/applyInitialLayerVisibility.ts +3 -3
  159. package/src/utils/centerOnStation.ts +3 -2
  160. package/src/utils/centerOnVehicle.ts +5 -4
  161. package/src/utils/constants.ts +17 -3
  162. package/src/utils/exportPdf.ts +26 -20
  163. package/src/utils/fullTrajectoryStyle.ts +2 -2
  164. package/src/utils/getAllLayers.ts +4 -3
  165. package/src/utils/getDelayColor.test.ts +1 -0
  166. package/src/utils/getDelayColorForVehicle.test.ts +2 -0
  167. package/src/utils/getDelayString.test.ts +3 -0
  168. package/src/utils/getDelayTextForVehicle.test.ts +4 -0
  169. package/src/utils/getFullTrajectoryAndFit.ts +4 -3
  170. package/src/utils/getHoursAndMinutes.test.ts +1 -0
  171. package/src/utils/getLayersAsFlatArray.ts +2 -2
  172. package/src/utils/getLinkByDevice.ts +1 -1
  173. package/src/utils/getMainColorForVehicle.ts +3 -3
  174. package/src/utils/getPermalinkParameters.ts +2 -2
  175. package/src/utils/getStopStatus.test.ts +2 -1
  176. package/src/utils/getStopStatus.ts +1 -1
  177. package/src/utils/getTextForVehicle.ts +1 -1
  178. package/src/utils/hooks/useDeparture.tsx +6 -5
  179. package/src/utils/hooks/useI18n.tsx +6 -4
  180. package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
  181. package/src/utils/hooks/useLayerConfig.tsx +39 -0
  182. package/src/utils/hooks/useMapContext.tsx +30 -18
  183. package/src/utils/hooks/useRouteStop.tsx +3 -2
  184. package/src/utils/hooks/useRvfContext.tsx +11 -3
  185. package/src/utils/hooks/useStation.tsx +2 -1
  186. package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
  187. package/src/utils/hooks/useZoom.tsx +4 -4
  188. package/src/utils/realtimeRVFStyle.ts +5 -4
  189. package/src/utils/sharingGraphqlUtils.ts +3 -2
  190. package/src/utils/sharingStylesUtils.ts +7 -7
  191. package/src/utils/sharingWFSUtils.ts +9 -15
  192. package/tailwind.config.mjs +1 -0
  193. package/tsconfig.json +1 -1
  194. package/doc/tailwind.config.ts +0 -20
  195. package/src/utils/getFeatureInformationTitle.tsx +0 -54
@@ -1,8 +1,5 @@
1
- import { GeoJSONSource } from "maplibre-gl";
2
- import { Feature, MapBrowserEvent } from "ol";
3
1
  import { GeoJSON } from "ol/format";
4
2
  import { unByKey } from "ol/Observable";
5
- import { toLonLat } from "ol/proj";
6
3
  import { useCallback, useEffect } from "preact/hooks";
7
4
 
8
5
  import { PROVIDER_LOGOS_BY_FEED_ID } from "../utils/constants";
@@ -11,12 +8,16 @@ import useRvfContext from "../utils/hooks/useRvfContext";
11
8
  import MobilityEvent from "../utils/MobilityEvent";
12
9
  import { fetchSharingStation } from "../utils/sharingGraphqlUtils";
13
10
 
11
+ import type { GeoJSONSource } from "maplibre-gl";
12
+ import type { Feature, MapBrowserEvent } from "ol";
13
+
14
14
  const geojson = new GeoJSON();
15
15
 
16
- function SingleClickListener() {
16
+ function SingleClickListener({ eventNode }: { eventNode: HTMLElement }) {
17
17
  const {
18
18
  baseLayer,
19
19
  map,
20
+ queryablelayers,
20
21
  realtimeLayer,
21
22
  setStationId,
22
23
  setTrainId,
@@ -30,22 +31,19 @@ function SingleClickListener() {
30
31
 
31
32
  // Send the selctedFEature to the parent window
32
33
  useEffect(() => {
33
- if (!map) {
34
- return;
35
- }
36
-
37
- map.getTargetElement().dispatchEvent(
38
- new MobilityEvent("selectedfeature", {
34
+ eventNode?.dispatchEvent(
35
+ new MobilityEvent("mwc:selectedfeature", {
39
36
  feature: selectedFeature
40
37
  ? geojson.writeFeatureObject(selectedFeature)
41
38
  : null,
42
39
  }),
43
40
  );
44
- }, [map, selectedFeature]);
41
+ }, [eventNode, selectedFeature]);
45
42
 
46
43
  const onPointerMove = useCallback(
47
- async (evt: MapBrowserEvent<PointerEvent>) => {
44
+ (evt: MapBrowserEvent<PointerEvent>) => {
48
45
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
46
+ hitTolerance: 5,
49
47
  layerFilter: (l) => {
50
48
  return l === realtimeLayer;
51
49
  },
@@ -65,7 +63,9 @@ function SingleClickListener() {
65
63
  // Send all the features under the cursor
66
64
  const features = evt.map.getFeaturesAtPixel(evt.pixel, {
67
65
  layerFilter: (l) => {
68
- return l.get("isQueryable");
66
+ return queryablelayers
67
+ ? queryablelayers.split(",").includes(l.get("name"))
68
+ : l.get("isQueryable");
69
69
  },
70
70
  }) as Feature[];
71
71
 
@@ -74,15 +74,16 @@ function SingleClickListener() {
74
74
  ? "pointer"
75
75
  : "default";
76
76
  },
77
- [realtimeLayer, stationsLayer, tenant],
77
+ [queryablelayers, realtimeLayer, stationsLayer, tenant],
78
78
  );
79
79
 
80
80
  const onSingleClick = useCallback(
81
- async (evt: MapBrowserEvent<PointerEvent>) => {
82
- if (!baseLayer.mapLibreMap) {
81
+ (evt: MapBrowserEvent<PointerEvent>) => {
82
+ if (!baseLayer?.mapLibreMap) {
83
83
  return;
84
84
  }
85
85
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
86
+ hitTolerance: 5,
86
87
  layerFilter: (l) => {
87
88
  return l === realtimeLayer;
88
89
  },
@@ -114,22 +115,26 @@ function SingleClickListener() {
114
115
 
115
116
  // Send all the features under the cursor
116
117
  const features = evt.map.getFeaturesAtPixel(evt.pixel, {
118
+ hitTolerance: 5,
117
119
  layerFilter: (l) => {
118
- return l.get("isQueryable");
120
+ console.log(queryablelayers);
121
+ return queryablelayers
122
+ ? queryablelayers.split(",").includes(l.get("name"))
123
+ : l.get("isQueryable");
119
124
  },
120
125
  }) as Feature[];
121
126
 
122
127
  // Append more infos about the features
123
- const addMoreData = async (features) => {
124
- for (const feature of features) {
128
+ const addMoreData = async (featuress) => {
129
+ for (const feature of featuress) {
125
130
  const clusterId = feature.get("cluster_id");
126
131
  if (clusterId) {
127
132
  const vtFeat = feature.get("vectorTileFeature");
128
133
  const sourceId = vtFeat.layer.source;
129
134
  const leaves =
130
- (await (
131
- baseLayer.mapLibreMap.getSource(sourceId) as GeoJSONSource
132
- )?.getClusterLeaves(clusterId, 1000, 0)) || [];
135
+ (await baseLayer.mapLibreMap
136
+ .getSource<GeoJSONSource>(sourceId)
137
+ ?.getClusterLeaves(clusterId, 1000, 0)) || [];
133
138
 
134
139
  feature.set(
135
140
  "features",
@@ -151,23 +156,32 @@ function SingleClickListener() {
151
156
  );
152
157
  }
153
158
  }
154
- evt.map.getTargetElement().dispatchEvent(
155
- new MobilityEvent("singleclick", {
156
- ...evt,
157
- features: geojson.writeFeaturesObject(features),
158
- lonlat: toLonLat(evt.coordinate),
159
- }),
160
- );
159
+ // evt.map.getTargetElement().dispatchEvent(
160
+ // new MobilityEvent("singleclick", {
161
+ // ...evt,
162
+ // features: geojson.writeFeaturesObject(features),
163
+ // lonlat: toLonLat(evt.coordinate),
164
+ // }),
165
+ // );
161
166
 
162
167
  if (newStationId || newTrainId || !features.length) {
163
168
  setSelectedFeature(null);
164
169
  setSelectedFeatures([]);
165
170
  } else {
166
171
  setSelectedFeatures(features);
167
- setSelectedFeature(features[0]);
172
+
173
+ // We prioritize some layers like the notification one over the others
174
+ const notificationFeature = features.find((feat) => {
175
+ return feat.get("severity");
176
+ });
177
+ if (notificationFeature) {
178
+ setSelectedFeature(notificationFeature);
179
+ } else {
180
+ setSelectedFeature(features[0]);
181
+ }
168
182
  }
169
183
  };
170
- addMoreData(features);
184
+ void addMoreData(features);
171
185
  },
172
186
  [
173
187
  baseLayer?.mapLibreMap,
@@ -178,6 +192,7 @@ function SingleClickListener() {
178
192
  tenant,
179
193
  setStationId,
180
194
  setTrainId,
195
+ queryablelayers,
181
196
  selectedFeature,
182
197
  setSelectedFeature,
183
198
  setSelectedFeatures,
@@ -1,5 +1,4 @@
1
1
  import { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
2
- import { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
3
2
  import { memo } from "preact/compat";
4
3
  import { useEffect, useMemo } from "preact/hooks";
5
4
 
@@ -7,6 +6,8 @@ import { RVF_LAYERS_NAMES } from "../utils/constants";
7
6
  import useMapContext from "../utils/hooks/useMapContext";
8
7
  import useRvfContext from "../utils/hooks/useRvfContext";
9
8
 
9
+ import type { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
10
+
10
11
  function RvfTarifZonenLayer(props: MaplibreStyleLayerOptions) {
11
12
  const { baseLayer, map } = useMapContext();
12
13
  const { setTarifZonenLayer } = useRvfContext();
@@ -1,8 +1,5 @@
1
1
  import { getUid } from "ol";
2
- import { Group } from "ol/layer";
3
- import BaseLayer from "ol/layer/Base";
4
2
  import { unByKey } from "ol/Observable";
5
- import { JSX, PreactDOMAttributes } from "preact";
6
3
  import { memo, useEffect, useMemo, useState } from "preact/compat";
7
4
 
8
5
  import RvfLayerTree from "../RvfLayerTree";
@@ -10,6 +7,10 @@ import { SelectionType } from "../RvfLayerTree/TreeItem/TreeItem";
10
7
  import getLayersAsFlatArray from "../utils/getLayersAsFlatArray";
11
8
  import useMapContext from "../utils/hooks/useMapContext";
12
9
 
10
+ import type { Group } from "ol/layer";
11
+ import type BaseLayer from "ol/layer/Base";
12
+ import type { JSX, PreactDOMAttributes } from "preact";
13
+
13
14
  export interface RvfLayerTreeConfig {
14
15
  childItems: RvfLayerTreeConfig[];
15
16
  id: string;
@@ -62,8 +63,8 @@ function RvfTopics(props: RvfTopicsProps) {
62
63
  // Force update of config when a layers`s visibility changes progammatically
63
64
  useEffect(() => {
64
65
  const keys = [];
65
- const layers = getLayersAsFlatArray(map.getLayers().getArray());
66
- layers.forEach((layer) => {
66
+ const layerss = getLayersAsFlatArray(map.getLayers().getArray());
67
+ layerss.forEach((layer) => {
67
68
  const key = layer.on("change:visible", () => {
68
69
  setRevision((prev) => {
69
70
  return prev + 1;
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "preact/hooks";
4
4
 
5
5
  import Minus from "../icons/Minus";
6
6
  import Plus from "../icons/Plus";
7
- import RvfIconButton from "../RvfIconButton";
7
+ import IconButton from "../ui/IconButton";
8
8
  import useMapContext from "../utils/hooks/useMapContext";
9
9
 
10
10
  function RvfZoomButtons() {
@@ -56,12 +56,12 @@ function RvfZoomButtons() {
56
56
 
57
57
  return (
58
58
  <>
59
- <RvfIconButton
59
+ <IconButton
60
60
  disabled={isZoomInDisabled}
61
61
  Icon={Plus}
62
62
  onClick={handleZoomIn}
63
63
  />
64
- <RvfIconButton
64
+ <IconButton
65
65
  disabled={isZoomOutDisabled}
66
66
  Icon={Minus}
67
67
  onClick={handleZoomOut}
@@ -1,13 +1,14 @@
1
- import ScaleLineControl, {
2
- Options as ScaleLineOptions,
3
- } from "ol/control/ScaleLine";
4
- import { JSX, PreactDOMAttributes } from "preact";
1
+ import ScaleLineControl from "ol/control/ScaleLine";
5
2
  import { useEffect, useMemo, useState } from "preact/hooks";
6
3
 
7
4
  import useMapContext from "../utils/hooks/useMapContext";
5
+
8
6
  // @ts-expect-error bad type definition
9
7
  import style from "./index.css";
10
8
 
9
+ import type { Options as ScaleLineOptions } from "ol/control/ScaleLine";
10
+ import type { JSX, PreactDOMAttributes } from "preact";
11
+
11
12
  type ScaleLineProps = {
12
13
  options?: ScaleLineOptions;
13
14
  } & JSX.HTMLAttributes<HTMLDivElement> &
@@ -1,6 +1,7 @@
1
- import { JSX, PreactDOMAttributes } from "preact";
2
1
  import { useEffect, useState } from "preact/hooks";
3
2
 
3
+ import type { JSX, PreactDOMAttributes } from "preact";
4
+
4
5
  export type ScrollableHandlerProps = JSX.HTMLAttributes<HTMLDivElement> &
5
6
  PreactDOMAttributes;
6
7
 
@@ -1 +1 @@
1
- export { default } from "./ScrollableHandler";
1
+ export { default, ScrollableHandlerProps } from "./ScrollableHandler";
@@ -1,13 +1,17 @@
1
- import { Feature, MapBrowserEvent } from "ol";
2
1
  import { unByKey } from "ol/Observable";
3
2
  import { useCallback, useEffect } from "preact/hooks";
4
3
 
5
4
  import useMapContext from "../utils/hooks/useMapContext";
6
5
 
6
+ import type { Feature, MapBrowserEvent } from "ol";
7
+
7
8
  function SingleClickListener() {
8
9
  const {
9
10
  map,
11
+ // queryablelayers,
10
12
  realtimeLayer,
13
+ setSelectedFeature,
14
+ setSelectedFeatures,
11
15
  setStationId,
12
16
  setTrainId,
13
17
  stationId,
@@ -17,8 +21,9 @@ function SingleClickListener() {
17
21
  } = useMapContext();
18
22
 
19
23
  const onPointerMove = useCallback(
20
- async (evt: MapBrowserEvent<PointerEvent>) => {
24
+ (evt: MapBrowserEvent<PointerEvent>) => {
21
25
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
26
+ hitTolerance: 5,
22
27
  layerFilter: (l) => {
23
28
  return l === realtimeLayer;
24
29
  },
@@ -35,15 +40,35 @@ function SingleClickListener() {
35
40
  return feat.get("tralis_network")?.includes(tenant);
36
41
  });
37
42
 
43
+ // Send all the features under the cursor
44
+ const features = evt.map.getFeaturesAtPixel(evt.pixel, {
45
+ layerFilter: (l) => {
46
+ return l.get("isQueryable");
47
+ },
48
+ }) as Feature[];
49
+
38
50
  evt.map.getTargetElement().style.cursor =
39
- realtimeFeature || stationFeature ? "pointer" : "default";
51
+ realtimeFeature || stationFeature || features?.length
52
+ ? "pointer"
53
+ : "default";
40
54
  },
41
55
  [realtimeLayer, stationsLayer, tenant],
42
56
  );
43
57
 
44
58
  const onSingleClick = useCallback(
45
- async (evt: MapBrowserEvent<PointerEvent>) => {
59
+ (evt: MapBrowserEvent<PointerEvent>) => {
60
+ // const qeryableLayers = queryablelayers?.split(",");
61
+ // const featuress = evt.map.getFeaturesAtPixel(evt.pixel, {
62
+ // layerFilter: (l) => {
63
+ // return qeryableLayers
64
+ // ? queryablelayers.includes(l.get("name"))
65
+ // : true;
66
+ // },
67
+ // });
68
+ // console.log("featursss", featuress);
69
+
46
70
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
71
+ hitTolerance: 5,
47
72
  layerFilter: (l) => {
48
73
  return l === realtimeLayer;
49
74
  },
@@ -72,8 +97,24 @@ function SingleClickListener() {
72
97
  setTrainId(null);
73
98
  setStationId(null);
74
99
  }
100
+
101
+ // Send all the features under the cursor
102
+ const features = evt.map.getFeaturesAtPixel(evt.pixel, {
103
+ layerFilter: (l) => {
104
+ return l.get("isQueryable");
105
+ },
106
+ }) as Feature[];
107
+
108
+ if (newStationId || newTrainId || !features.length) {
109
+ setSelectedFeature(null);
110
+ setSelectedFeatures([]);
111
+ } else {
112
+ setSelectedFeatures(features);
113
+ setSelectedFeature(features[0]);
114
+ }
75
115
  },
76
116
  [
117
+ // queryablelayers,
77
118
  stationId,
78
119
  trainId,
79
120
  realtimeLayer,
@@ -81,6 +122,8 @@ function SingleClickListener() {
81
122
  tenant,
82
123
  setStationId,
83
124
  setTrainId,
125
+ setSelectedFeature,
126
+ setSelectedFeatures,
84
127
  ],
85
128
  );
86
129
 
@@ -1,7 +1,4 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import { debounceDeparturesMessages } from "mobility-toolbox-js/ol";
4
- import { RealtimeDeparture } from "mobility-toolbox-js/types";
5
2
  import { memo } from "preact/compat";
6
3
  import { useEffect, useRef, useState } from "preact/hooks";
7
4
 
@@ -9,6 +6,9 @@ import Departure from "../Departure";
9
6
  import StationHeader from "../StationHeader";
10
7
  import useMapContext from "../utils/hooks/useMapContext";
11
8
 
9
+ import type { RealtimeDeparture } from "mobility-toolbox-js/types";
10
+ import type { JSX, PreactDOMAttributes } from "preact";
11
+
12
12
  export type StationProps = JSX.HTMLAttributes<HTMLDivElement> &
13
13
  PreactDOMAttributes;
14
14
 
@@ -24,8 +24,8 @@ function Station(props: StationProps) {
24
24
  }
25
25
 
26
26
  const onMessage = debounceDeparturesMessages(
27
- (departures: RealtimeDeparture[]) => {
28
- setDepartures(departures);
27
+ (newDepartures: RealtimeDeparture[]) => {
28
+ setDepartures(newDepartures);
29
29
  return null;
30
30
  },
31
31
  false,
@@ -1,8 +1,8 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
- import { RealtimeStation } from "mobility-toolbox-js/types";
4
1
  import { memo } from "preact/compat";
5
2
 
3
+ import type { RealtimeStation } from "mobility-toolbox-js/types";
4
+ import type { JSX, PreactDOMAttributes } from "preact";
5
+
6
6
  export type StationNameProps = {
7
7
  station: RealtimeStation;
8
8
  } & JSX.HTMLAttributes<HTMLDivElement> &
@@ -1,6 +1,3 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
- import { RealtimeStation } from "mobility-toolbox-js/types";
4
1
  import { memo } from "preact/compat";
5
2
 
6
3
  import Airport from "../icons/Airport";
@@ -12,6 +9,9 @@ import Police from "../icons/Police";
12
9
  import WaitingAreas from "../icons/WaitingAreas";
13
10
  import WheelChair from "../icons/WheelChair";
14
11
 
12
+ import type { RealtimeStation } from "mobility-toolbox-js/types";
13
+ import type { JSX, PreactDOMAttributes } from "preact";
14
+
15
15
  export type StationServicesProps = {
16
16
  accessibility?: boolean;
17
17
  airport?: boolean;
@@ -1,12 +1,13 @@
1
1
  import { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
2
- import { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
3
2
  import { memo } from "preact/compat";
4
3
  import { useEffect, useMemo } from "preact/hooks";
5
4
 
6
- import { RVF_LAYERS_NAMES } from "../utils/constants";
5
+ import { LAYER_NAME_STATIONS } from "../utils/constants";
7
6
  import useMapContext from "../utils/hooks/useMapContext";
8
7
 
9
- function StationsLayer(props: MaplibreStyleLayerOptions) {
8
+ import type { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol";
9
+
10
+ function StationsLayer(props: Partial<MaplibreStyleLayerOptions>) {
10
11
  const { baseLayer, map, setStationsLayer } = useMapContext();
11
12
 
12
13
  const layer = useMemo(() => {
@@ -18,7 +19,7 @@ function StationsLayer(props: MaplibreStyleLayerOptions) {
18
19
  return metadata?.["general.filter"] === "stations";
19
20
  },
20
21
  maplibreLayer: baseLayer,
21
- name: RVF_LAYERS_NAMES.haltestellen,
22
+ name: LAYER_NAME_STATIONS,
22
23
  ...(props || {}),
23
24
  });
24
25
  }, [baseLayer, props]);