diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index d709fe0..bf0d4f2 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -27,11 +27,136 @@ function App() {
dataSources
.filter(({ id }) => selectedSources.includes(id))
.map(({ url }) => fetch(url).then((res) => res.json()))
- )).flat().map(({ latitude, longitude, objectType }) => ({
- coords: [latitude, longitude],
- popup: objectType,
- icon: objectType,
- }));
+ ))
+ .flat()
+ .map((item) => {
+ let icon = item.objectType;
+ let popupContent;
+ let objectTitle;
+
+ switch (item.objectType) {
+ case "IrishRailTrain":
+ objectTitle = "Irish Rail Train: " + item.trainCode;
+
+ let trainType;
+ switch (item.trainType) {
+ case "M":
+ trainType = "Mainline";
+ icon = "mainline";
+ break;
+ case "S":
+ trainType = "Suburban";
+ icon = "suburban";
+ break;
+ case "D":
+ trainType = "DART";
+ icon = "dart";
+ break;
+ default:
+ trainType = "Unknown";
+ }
+
+ let trainStatus;
+ switch (item.trainStatus) {
+ case "R":
+ trainStatus = "Running";
+ break;
+ default:
+ trainStatus = "Not running"
+ }
+
+ const splitMessage = item.trainPublicMessage.split("\\n");
+ const match = splitMessage[1].match(/\((.*?)\)/);
+ const punctuality = match ? match[1] : "N/A";
+
+ // set icon depending on lateness of train and type of train
+ if (trainStatus == "Not running") {
+ icon += "NotRunning";
+ }
+ else if (punctuality.charAt(0) === "-" || punctuality.charAt(0) === "0") {
+ icon += "OnTime";
+ }
+ else {
+ icon += "Late"
+ }
+
+ popupContent = (
+
+
{objectTitle}
+
+ - Train Details: {splitMessage[1].split("(")[0]}
+ - Train Type: {trainType}
+ - Status: {trainStatus}
+ - Direction: {item.trainDirection}
+ - Update: {splitMessage[2]}
+ - Punctuality: {punctuality}
+
+
+ );
+ break;
+
+ case "IrishRailStation":
+ objectTitle = item.trainStationDesc + " Train Station";
+
+ popupContent = (
+
+
{objectTitle}
+
+ - Train Station Name: {item.trainStationDesc}
+ - Train Station ID: {item.trainStationID}
+ - Train Station Code: {item.trainStationCode}
+
+
+ );
+ break;
+
+ case "Bus":
+ objectTitle = item.busRouteAgencyName + ": " + item.busRouteShortName;
+
+ popupContent = (
+
+
{objectTitle}
+
+ - Bus ID: {item.busID}
+ - Bus Route ID: {item.busRoute}
+ - Bus Route Short Name: {item.busRouteShortName}
+ - Bus Route Long Name: {item.busRouteLongName}
+ - Agency: {item.busRouteAgencyName}
+
+
+
+ );
+ break;
+
+ case "BusStop":
+ objectTitle = item.busStopName + " Bus Stop";
+
+ popupContent = (
+
+
{objectTitle}
+
+ - Bus Stop ID: {item.busStopID}
+ - Bus Stop Name: {item.busStopName}
+ - Bus Stop Code: {item.busStopCode || "N/A"}
+
+
+ );
+ break;
+
+ default:
+ popupContent = (
+
+
{item.objectType}
+
+ );
+ }
+
+ return {
+ coords: [item.latitude, item.longitude],
+ popup: popupContent,
+ icon: icon,
+ };
+ });
setMarkers(newMarkers);
} catch (error) {
console.error("Error fetching data:", error);
diff --git a/frontend/src/components/MapComponent.jsx b/frontend/src/components/MapComponent.jsx
index 00cc2aa..219081d 100644
--- a/frontend/src/components/MapComponent.jsx
+++ b/frontend/src/components/MapComponent.jsx
@@ -8,7 +8,17 @@ import "leaflet.markercluster/dist/MarkerCluster.Default.css";
import trainStationIconURL from "../assets/icons/train-station.png";
import trainIconURL from "../assets/icons/train.png";
+
+import trainNotRunningIconURL from "../assets/icons/trainNotRunning.png";
+import trainOnTimeIconURL from "../assets/icons/train_ontime.png";
+import trainLateIconURL from "../assets/icons/train_late.png";
+
+import dartNotRunningIconURL from "../assets/icons/DARTnotRunning.png";
+import dartOnTimeIconURL from "../assets/icons/DARTOnTime.png";
+import dartLateIconURL from "../assets/icons/DARTLate.png";
+
import luasIconURL from "../assets/icons/tram-station.png";
+
import busStopIconURL from "../assets/icons/bus-station.png";
import busIconURL from "../assets/icons/bus.png";
@@ -23,6 +33,19 @@ L.Icon.Default.mergeOptions({
const icons = new Map([
["IrishRailStation", new Icon({ iconUrl: trainStationIconURL, iconSize: [24, 24] })],
["IrishRailTrain", new Icon({ iconUrl: trainIconURL, iconSize: [38, 38] })],
+
+ ["mainlineNotRunning", new Icon({ iconUrl: trainNotRunningIconURL, iconSize: [38, 38] })],
+ ["mainlineOnTime", new Icon({ iconUrl: trainOnTimeIconURL, iconSize: [38, 38] })],
+ ["mainlineLate", new Icon({ iconUrl: trainLateIconURL, iconSize: [38, 38] })],
+
+ ["suburbanNotRunning", new Icon({ iconUrl: trainNotRunningIconURL, iconSize: [38, 38] })],
+ ["suburbanOnTime", new Icon({ iconUrl: trainOnTimeIconURL, iconSize: [38, 38] })],
+ ["suburbanLate", new Icon({ iconUrl: trainLateIconURL, iconSize: [38, 38] })],
+
+ ["dartNotRunning", new Icon({ iconUrl: dartNotRunningIconURL, iconSize: [38, 38] })],
+ ["dartOnTime", new Icon({ iconUrl: dartOnTimeIconURL, iconSize: [38, 38] })],
+ ["dartLate", new Icon({ iconUrl: dartLateIconURL, iconSize: [38, 38] })],
+
["LuasStop", new Icon({ iconUrl: luasIconURL, iconSize: [38, 38] })],
["BusStop", new Icon({ iconUrl: busStopIconURL, iconSize: [24, 24] })],
["Bus", new Icon({ iconUrl: busIconURL, iconSize: [38, 38] })],