@geops/rvf-mobility-web-component 0.1.46 → 0.1.47

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 (204) hide show
  1. package/.prettierrc.js +3 -1
  2. package/CHANGELOG.md +12 -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 +181 -207
  16. package/index.html +108 -88
  17. package/index.js +2345 -1976
  18. package/input.css +21 -3
  19. package/package.json +39 -41
  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 +252 -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 +36 -5
  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 +25 -21
  73. package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +131 -127
  74. package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +309 -111
  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/RvfFeatureDetailsFooter/RvfFeatureDetailsFooter.tsx +43 -0
  80. package/src/RvfFeatureDetailsFooter/index.tsx +1 -0
  81. package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
  82. package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
  83. package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
  84. package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
  85. package/src/RvfGeolocationButton/index.tsx +1 -0
  86. package/src/RvfIconButton/RvfIconButton.tsx +20 -9
  87. package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
  88. package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
  89. package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
  90. package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
  91. package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
  92. package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
  93. package/src/RvfLink/RvfLink.tsx +4 -3
  94. package/src/RvfMobilityMap/RvfMobilityMap.tsx +324 -320
  95. package/src/RvfModal/RvfModal.tsx +4 -3
  96. package/src/RvfOverlayContent/RvfOverlayContent.tsx +128 -0
  97. package/src/RvfOverlayContent/index.ts +0 -0
  98. package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
  99. package/src/RvfPermalink/RvfPermalink.tsx +2 -2
  100. package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
  101. package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
  102. package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
  103. package/src/RvfRouteIcon/index.tsx +1 -0
  104. package/src/RvfSearch/RvfSearch.tsx +4 -1
  105. package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
  106. package/src/RvfSearchButton/index.tsx +1 -0
  107. package/src/RvfSelect/RvfSelect.tsx +7 -5
  108. package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
  109. package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
  110. package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
  111. package/src/RvfShare/RvfShare.tsx +11 -10
  112. package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
  113. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
  114. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +102 -67
  115. package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
  116. package/src/RvfTopics/RvfTopics.tsx +6 -5
  117. package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
  118. package/src/ScaleLine/ScaleLine.tsx +5 -4
  119. package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
  120. package/src/ScrollableHandler/index.tsx +1 -1
  121. package/src/SingleClickListener/SingleClickListener.tsx +47 -4
  122. package/src/Station/Station.tsx +5 -5
  123. package/src/StationName/StationName.tsx +3 -3
  124. package/src/StationServices/StationServices.tsx +3 -3
  125. package/src/StationsLayer/StationsLayer.tsx +5 -4
  126. package/src/StopsSearch/StopsSearch.tsx +143 -88
  127. package/src/WindowMessageListener/WindowMessageListener.tsx +68 -0
  128. package/src/WindowMessageListener/index.tsx +1 -0
  129. package/src/icons/Airport/Airport.tsx +4 -4
  130. package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
  131. package/src/icons/ArrowRight/ArrowRight.tsx +19 -0
  132. package/src/icons/ArrowRight/arrow-right.svg +16 -0
  133. package/src/icons/ArrowRight/index.tsx +1 -0
  134. package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
  135. package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
  136. package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
  137. package/src/icons/Bathroom/Bathroom.tsx +1 -1
  138. package/src/icons/Copy/Copy.tsx +1 -1
  139. package/src/icons/Doc/Doc.tsx +1 -1
  140. package/src/icons/Email/Email.tsx +1 -1
  141. package/src/icons/FilePdf/FilePdf.tsx +1 -1
  142. package/src/icons/Geolocation/Geolocation.tsx +3 -5
  143. package/src/icons/Image/Image.tsx +1 -1
  144. package/src/icons/Menu/Menu.tsx +1 -1
  145. package/src/icons/Minus/Minus.tsx +1 -1
  146. package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
  147. package/src/icons/Plus/Plus.tsx +1 -1
  148. package/src/icons/Police/Police.tsx +3 -3
  149. package/src/icons/Search/Search.tsx +0 -1
  150. package/src/icons/Share/Share.tsx +1 -1
  151. package/src/icons/Stack/Stack.tsx +1 -1
  152. package/src/icons/Tracking/Tracking.tsx +29 -0
  153. package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
  154. package/src/icons/Tracking/index.tsx +1 -0
  155. package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
  156. package/src/icons/Warning/Warning.tsx +56 -0
  157. package/src/icons/Warning/index.tsx +1 -0
  158. package/src/icons/Warning/info-achtung-kreisrot-rot.svg +28 -0
  159. package/src/icons/WheelChair/WheelChair.tsx +1 -1
  160. package/src/index.tsx +8 -46
  161. package/src/indexDoc.ts +13 -0
  162. package/src/ui/Button/Button.tsx +57 -0
  163. package/src/ui/Button/index.tsx +1 -0
  164. package/src/ui/IconButton/IconButton.tsx +44 -0
  165. package/src/ui/IconButton/index.tsx +1 -0
  166. package/src/utils/MobilityEvent.ts +4 -3
  167. package/src/utils/applyInitialLayerVisibility.ts +3 -3
  168. package/src/utils/centerOnStation.ts +3 -2
  169. package/src/utils/centerOnVehicle.ts +5 -4
  170. package/src/utils/constants.ts +27 -3
  171. package/src/utils/exportPdf.ts +26 -20
  172. package/src/utils/fullTrajectoryStyle.ts +2 -2
  173. package/src/utils/getAllLayers.ts +4 -3
  174. package/src/utils/getDelayColor.test.ts +1 -0
  175. package/src/utils/getDelayColorForVehicle.test.ts +2 -0
  176. package/src/utils/getDelayString.test.ts +3 -0
  177. package/src/utils/getDelayTextForVehicle.test.ts +4 -0
  178. package/src/utils/getFullTrajectoryAndFit.ts +4 -3
  179. package/src/utils/getHoursAndMinutes.test.ts +1 -0
  180. package/src/utils/getLayersAsFlatArray.ts +2 -2
  181. package/src/utils/getLinkByDevice.ts +1 -1
  182. package/src/utils/getMainColorForVehicle.ts +3 -3
  183. package/src/utils/getPermalinkParameters.ts +2 -2
  184. package/src/utils/getStopStatus.test.ts +2 -1
  185. package/src/utils/getStopStatus.ts +1 -1
  186. package/src/utils/getTextForVehicle.ts +1 -1
  187. package/src/utils/hooks/useDeparture.tsx +6 -5
  188. package/src/utils/hooks/useI18n.tsx +6 -4
  189. package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
  190. package/src/utils/hooks/useLayerConfig.tsx +40 -0
  191. package/src/utils/hooks/useMapContext.tsx +30 -18
  192. package/src/utils/hooks/useRouteStop.tsx +3 -2
  193. package/src/utils/hooks/useRvfContext.tsx +11 -3
  194. package/src/utils/hooks/useStation.tsx +2 -1
  195. package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
  196. package/src/utils/hooks/useZoom.tsx +4 -4
  197. package/src/utils/realtimeRVFStyle.ts +5 -4
  198. package/src/utils/sharingGraphqlUtils.ts +3 -2
  199. package/src/utils/sharingStylesUtils.ts +7 -7
  200. package/src/utils/sharingWFSUtils.ts +9 -15
  201. package/tailwind.config.mjs +1 -0
  202. package/tsconfig.json +1 -1
  203. package/doc/tailwind.config.ts +0 -20
  204. package/src/utils/getFeatureInformationTitle.tsx +0 -54
@@ -1,22 +1,28 @@
1
- import { GeoJSONSource } from "maplibre-gl";
2
- import { Feature, MapBrowserEvent } from "ol";
1
+ import { getFeatureInfoAtCoordinate } from "mobility-toolbox-js/ol";
3
2
  import { GeoJSON } from "ol/format";
4
3
  import { unByKey } from "ol/Observable";
5
- import { toLonLat } from "ol/proj";
6
4
  import { useCallback, useEffect } from "preact/hooks";
7
5
 
8
- import { PROVIDER_LOGOS_BY_FEED_ID } from "../utils/constants";
6
+ import {
7
+ LAYER_NAME_REALTIME,
8
+ LAYER_NAME_STATIONS,
9
+ PROVIDER_LOGOS_BY_FEED_ID,
10
+ } from "../utils/constants";
9
11
  import useMapContext from "../utils/hooks/useMapContext";
10
12
  import useRvfContext from "../utils/hooks/useRvfContext";
11
13
  import MobilityEvent from "../utils/MobilityEvent";
12
14
  import { fetchSharingStation } from "../utils/sharingGraphqlUtils";
13
15
 
16
+ import type { GeoJSONSource } from "maplibre-gl";
17
+ import type { Feature, MapBrowserEvent } from "ol";
18
+
14
19
  const geojson = new GeoJSON();
15
20
 
16
- function SingleClickListener() {
21
+ function SingleClickListener({ eventNode }: { eventNode: HTMLElement }) {
17
22
  const {
18
23
  baseLayer,
19
24
  map,
25
+ queryablelayers,
20
26
  realtimeLayer,
21
27
  setStationId,
22
28
  setTrainId,
@@ -30,22 +36,19 @@ function SingleClickListener() {
30
36
 
31
37
  // Send the selctedFEature to the parent window
32
38
  useEffect(() => {
33
- if (!map) {
34
- return;
35
- }
36
-
37
- map.getTargetElement().dispatchEvent(
38
- new MobilityEvent("selectedfeature", {
39
+ eventNode?.dispatchEvent(
40
+ new MobilityEvent("mwc:selectedfeature", {
39
41
  feature: selectedFeature
40
42
  ? geojson.writeFeatureObject(selectedFeature)
41
43
  : null,
42
44
  }),
43
45
  );
44
- }, [map, selectedFeature]);
46
+ }, [eventNode, selectedFeature]);
45
47
 
46
48
  const onPointerMove = useCallback(
47
- async (evt: MapBrowserEvent<PointerEvent>) => {
49
+ (evt: MapBrowserEvent<PointerEvent>) => {
48
50
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
51
+ hitTolerance: 5,
49
52
  layerFilter: (l) => {
50
53
  return l === realtimeLayer;
51
54
  },
@@ -65,7 +68,9 @@ function SingleClickListener() {
65
68
  // Send all the features under the cursor
66
69
  const features = evt.map.getFeaturesAtPixel(evt.pixel, {
67
70
  layerFilter: (l) => {
68
- return l.get("isQueryable");
71
+ return queryablelayers
72
+ ? queryablelayers.split(",").includes(l.get("name"))
73
+ : l.get("isQueryable");
69
74
  },
70
75
  }) as Feature[];
71
76
 
@@ -74,19 +79,21 @@ function SingleClickListener() {
74
79
  ? "pointer"
75
80
  : "default";
76
81
  },
77
- [realtimeLayer, stationsLayer, tenant],
82
+ [queryablelayers, realtimeLayer, stationsLayer, tenant],
78
83
  );
79
84
 
80
85
  const onSingleClick = useCallback(
81
86
  async (evt: MapBrowserEvent<PointerEvent>) => {
82
- if (!baseLayer.mapLibreMap) {
87
+ if (!baseLayer?.mapLibreMap) {
83
88
  return;
84
89
  }
85
90
  const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
91
+ hitTolerance: 5,
86
92
  layerFilter: (l) => {
87
93
  return l === realtimeLayer;
88
94
  },
89
- });
95
+ }) as Feature[];
96
+ realtimeFeature?.set("layerName", LAYER_NAME_REALTIME);
90
97
 
91
98
  const stationsFeatures = evt.map.getFeaturesAtPixel(evt.pixel, {
92
99
  layerFilter: (l) => {
@@ -95,7 +102,8 @@ function SingleClickListener() {
95
102
  });
96
103
  const [stationFeature] = stationsFeatures.filter((feat) => {
97
104
  return feat.get("tralis_network")?.includes(tenant);
98
- });
105
+ }) as Feature[];
106
+ stationFeature?.set("layerName", LAYER_NAME_STATIONS);
99
107
 
100
108
  const newStationId = stationFeature?.get("uid");
101
109
 
@@ -113,61 +121,87 @@ function SingleClickListener() {
113
121
  }
114
122
 
115
123
  // Send all the features under the cursor
116
- const features = evt.map.getFeaturesAtPixel(evt.pixel, {
117
- layerFilter: (l) => {
118
- return l.get("isQueryable");
119
- },
120
- }) as Feature[];
124
+ // const features = evt.map.getFeaturesAtPixel(evt.pixel, {
125
+ // hitTolerance: 5,
126
+ // layerFilter: (l) => {
127
+ // console.log(queryablelayers);
128
+ // return queryablelayers
129
+ // ? queryablelayers.split(",").includes(l.get("name"))
130
+ // : l.get("isQueryable");
131
+ // },
132
+ // }) as Feature[];
133
+
134
+ const queryableLayers = evt.map.getAllLayers().filter((l) => {
135
+ return queryablelayers
136
+ ? queryablelayers.split(",").includes(l.get("name"))
137
+ : l.get("isQueryable");
138
+ });
139
+ const featuresInfos = await getFeatureInfoAtCoordinate(
140
+ evt.coordinate,
141
+ queryableLayers,
142
+ 5,
143
+ true,
144
+ );
145
+
146
+ // Set the layerName as property of the feature
147
+ featuresInfos.forEach((f) => {
148
+ f.features.forEach((feat) => {
149
+ feat.set("layerName", f.layer.get("name"));
150
+ });
151
+ });
152
+
153
+ const features = featuresInfos.flatMap((f) => {
154
+ return f.features;
155
+ });
121
156
 
122
157
  // Append more infos about the features
123
- const addMoreData = async (features) => {
124
- for (const feature of features) {
125
- const clusterId = feature.get("cluster_id");
126
- if (clusterId) {
127
- const vtFeat = feature.get("vectorTileFeature");
128
- const sourceId = vtFeat.layer.source;
129
- const leaves =
130
- (await (
131
- baseLayer.mapLibreMap.getSource(sourceId) as GeoJSONSource
132
- )?.getClusterLeaves(clusterId, 1000, 0)) || [];
133
-
134
- feature.set(
135
- "features",
136
- leaves.map((l) => {
137
- return geojson.readFeature(l);
138
- }),
139
- );
140
- }
141
-
142
- // Sharing station
143
- const sharingStationId = selectedFeature?.get("station_id");
144
- if (sharingStationId) {
145
- const sharingStationInfo =
146
- await fetchSharingStation(sharingStationId);
147
- selectedFeature.setProperties(sharingStationInfo);
148
- selectedFeature.set(
149
- "provider_logo",
150
- PROVIDER_LOGOS_BY_FEED_ID[selectedFeature?.get("feed_id")],
151
- );
152
- }
158
+ for (const feature of features) {
159
+ const clusterId = feature.get("cluster_id");
160
+ if (clusterId) {
161
+ const vtFeat = feature.get("vectorTileFeature");
162
+ const sourceId = vtFeat.layer.source;
163
+ const leaves =
164
+ (await baseLayer.mapLibreMap
165
+ .getSource<GeoJSONSource>(sourceId)
166
+ ?.getClusterLeaves(clusterId, 1000, 0)) || [];
167
+
168
+ feature.set(
169
+ "features",
170
+ leaves.map((l) => {
171
+ return geojson.readFeature(l);
172
+ }),
173
+ );
174
+ }
175
+
176
+ // Sharing station
177
+ const sharingStationId = selectedFeature?.get("station_id");
178
+ if (sharingStationId) {
179
+ const sharingStationInfo =
180
+ await fetchSharingStation(sharingStationId);
181
+ selectedFeature.setProperties(sharingStationInfo);
182
+ selectedFeature.set(
183
+ "provider_logo",
184
+ PROVIDER_LOGOS_BY_FEED_ID[selectedFeature?.get("feed_id")],
185
+ );
153
186
  }
154
- evt.map.getTargetElement().dispatchEvent(
155
- new MobilityEvent("singleclick", {
156
- ...evt,
157
- features: geojson.writeFeaturesObject(features),
158
- lonlat: toLonLat(evt.coordinate),
159
- }),
160
- );
161
-
162
- if (newStationId || newTrainId || !features.length) {
163
- setSelectedFeature(null);
164
- setSelectedFeatures([]);
187
+ }
188
+
189
+ if (newStationId || newTrainId || !features.length) {
190
+ setSelectedFeature(null);
191
+ setSelectedFeatures([]);
192
+ } else {
193
+ setSelectedFeatures(features);
194
+
195
+ // We prioritize some layers like the notification one over the others
196
+ const notificationFeature = features.find((feat) => {
197
+ return feat.get("situation");
198
+ });
199
+ if (notificationFeature) {
200
+ setSelectedFeature(notificationFeature);
165
201
  } else {
166
- setSelectedFeatures(features);
167
202
  setSelectedFeature(features[0]);
168
203
  }
169
- };
170
- addMoreData(features);
204
+ }
171
205
  },
172
206
  [
173
207
  baseLayer?.mapLibreMap,
@@ -178,6 +212,7 @@ function SingleClickListener() {
178
212
  tenant,
179
213
  setStationId,
180
214
  setTrainId,
215
+ queryablelayers,
181
216
  selectedFeature,
182
217
  setSelectedFeature,
183
218
  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]);