diff --git a/frontend/src/stopsSearchMenu.tsx b/frontend/src/stopsSearchMenu.tsx
index 7b8222a..5456a37 100644
--- a/frontend/src/stopsSearchMenu.tsx
+++ b/frontend/src/stopsSearchMenu.tsx
@@ -407,6 +407,52 @@ const StopsPanels: ParentComponent<{ maxStopsPerPanel: number }> = (props) => {
);
}
+
+const StopPopup: ParentComponent<{ stop: Stop, show: boolean }> = (props) => {
+ const businessDataStore: BusinessDataStore | undefined = useContext(BusinessDataContext);
+ if (businessDataStore === undefined)
+ return
;
+
+ const { getLine, getStopDestinations } = businessDataStore;
+
+ let popupDiv: HTMLDivElement | undefined = undefined;
+
+ const getDestinations = async (stop: Stop): Promise<{ lineId: string, destinations: string[] }[]> => {
+ let ret = [];
+
+ if (stop !== undefined) {
+ const result = await getStopDestinations(stop.id);
+ for (const [lineId, destinations] of Object.entries(result)) {
+ const line = await getLine(lineId);
+ const linePicto = renderLinePicto(line);
+ ret.push({ lineId: linePicto, destinations: destinations });
+ }
+ }
+
+ return ret;
+ }
+ const [destinations] = createResource(() => props.stop, getDestinations);
+
+ return (
+
+
+
+
+ {(dst) => {
+ return ;
+ }}
+
+
+
+ );
+}
+
+
// TODO: Use boolean to set MapStop selected
const MapStop: VoidComponent<{ stop: Stop, selected: Stop | undefined }> = (props) => {
const businessDataStore: BusinessDataStore | undefined = useContext(BusinessDataContext);
@@ -482,52 +528,7 @@ const MapStop: VoidComponent<{ stop: Stop, selected: Stop | undefined }> = (prop
setMapFeature(props.stop.id, feature);
});
- {stop => }
-}
-
-
-const StopPopup: ParentComponent<{ stop: Stop, show: boolean }> = (props) => {
- const businessDataStore: BusinessDataStore | undefined = useContext(BusinessDataContext);
- if (businessDataStore === undefined)
- return ;
-
- const { getLine, getStopDestinations } = businessDataStore;
-
- let popupDiv: HTMLDivElement | undefined = undefined;
-
- const getDestinations = async (stop: Stop): Promise<{ lineId: string, destinations: string[] }[]> => {
- let ret = [];
-
- if (stop !== undefined) {
- const result = await getStopDestinations(stop.id);
- for (const [lineId, destinations] of Object.entries(result)) {
- const line = await getLine(lineId);
- const linePicto = renderLinePicto(line);
- ret.push({ lineId: linePicto, destinations: destinations });
- }
- }
-
- return ret;
- }
- const [destinations] = createResource(() => props.stop, getDestinations);
-
- return (
-
-
-
-
- {(dst) => {
- return ;
- }}
-
-
-
- );
+ return {stop => };
}
@@ -601,9 +602,7 @@ const Map: ParentComponent<{}> = () => {
const onClickedFeature = async (feature: OlFeatureLike): Promise => {
const stopId: number = feature.getId();
-
const stop = getStop(stopId);
-
// TODO: Handle StopArea (use center given by the backend)
if (stop?.lat !== undefined && stop?.lon !== undefined) {
setSelectedMapStop(stop);
@@ -613,7 +612,8 @@ const Map: ParentComponent<{}> = () => {
duration: 1000
},
// Display the popup once the animation finished
- () => setPopupDisplayed(true));
+ () => setPopupDisplayed(true)
+ );
}
}
@@ -621,20 +621,29 @@ const Map: ParentComponent<{}> = () => {
// Filling the map with stops shape
createEffect(() => {
- const features = getAllMapFeatures();
+ const stops = getFoundStops();
+ const foundStopIds = new Set();
+ for (const foundStop of stops) {
+ foundStopIds.add(foundStop.id);
+ foundStop.stops.forEach(s => foundStopIds.add(s.id));
+ }
- for (const [stopId, feature] of Object.entries(features)) {
- if (!(stopId in displayedFeatures)) {
- const stop = getStop(parseInt(stopId));
- stopVectorSource.addFeature(feature);
- displayedFeatures[stopId] = feature;
+ for (const [stopIdStr, feature] of Object.entries(displayedFeatures)) {
+ const stopId = parseInt(stopIdStr);
+ if (!foundStopIds.has(stopId)) {
+ console.log(`Remove feature for ${stopId}`);
+ stopVectorSource.removeFeature(feature);
+ delete displayedFeatures[stopId];
}
}
- for (const [stopId, feature] of Object.entries(displayedFeatures)) {
- if (!(stopId in features)) {
- stopVectorSource.removeFeature(feature);
- delete displayedFeatures[stopId];
+ const features = getAllMapFeatures();
+ for (const [stopIdStr, feature] of Object.entries(features)) {
+ const stopId = parseInt(stopIdStr);
+ if (foundStopIds.has(stopId) && !(stopId in displayedFeatures)) {
+ console.log(`Add feature for ${stopId}`);
+ stopVectorSource.addFeature(feature);
+ displayedFeatures[stopId] = feature;
}
}