diff --git a/scripts/map.js b/scripts/map.js index 0314fbb..4d65dff 100644 --- a/scripts/map.js +++ b/scripts/map.js @@ -171,7 +171,7 @@ async function loadStationMarkersFromArray(stationsArray, showDocks = false) { let iconStyle; - if (station.docks === 0) { + if (station.assetStatus === "repair") { // Deactivated station iconStyle = new ol.style.Style({ diff --git a/scripts/navigation.js b/scripts/navigation.js index 27bd963..9986d51 100644 --- a/scripts/navigation.js +++ b/scripts/navigation.js @@ -198,7 +198,7 @@ async function stopNavigation() { .forEach(layer => map.removeLayer(layer)); // Add back the stations layer (only if user has clicked navigate to stations) - getStations(); + loadStationMarkersFromArray(stationsArray); } // Show cycleways layer diff --git a/scripts/routing.js b/scripts/routing.js index e755125..e75587b 100644 --- a/scripts/routing.js +++ b/scripts/routing.js @@ -772,7 +772,7 @@ function addStationPointToMap(station, start = true) { }); let iconStyle; - if (station.docks !== 0) { + if (station.assetStatus === "active") { const bikeRatio = station.bikes / station.docks; const filled = station.bikes === 0 diff --git a/scripts/stations.js b/scripts/stations.js index 50b12f9..e098b6f 100644 --- a/scripts/stations.js +++ b/scripts/stations.js @@ -62,10 +62,6 @@ async function getStations() { ); if (typeof response !== "undefined") { - // Load the stations to the map - stationsArray = response.data.getStations; - loadStationMarkersFromArray(stationsArray); - return response.data.getStations; } } @@ -115,6 +111,7 @@ async function openStationMenu(stationSerialNumber) { const numDocks = stationObj.dockList.filter(d => d.lockStatus === "unlocked").length - numBikes; // number of free docks const distanceToStation = distance(pos, [lastStationObj.longitude, lastStationObj.latitude]); + console.log(stationObj); // set the inner HTML after the animation has started if (typeof bikeAndDocks.getBikes !== "undefined" && typeof bikeAndDocks.getDocks !== "undefined") { menu.innerHTML = ` @@ -129,7 +126,7 @@ async function openStationMenu(stationSerialNumber) {
${numDocks === 1 ? "1 doca" : `${numDocks} docas`}
Gira bike
${numBikes === 1 ? "1 bicicleta" : `${numBikes} bicicletas`}
`; @@ -192,7 +189,7 @@ function hideStationMenu(exitToRight = false) { .setVisible(true); // Add back the stations layer (only if user has clicked navigate to stations) - getStations(); + loadStationMarkersFromArray(stationsArray); } } diff --git a/scripts/user.js b/scripts/user.js index 79f8d11..15cbf0e 100644 --- a/scripts/user.js +++ b/scripts/user.js @@ -87,9 +87,6 @@ async function login(event) { } async function runStartupFunctions() { - // Start WebSocket connection - startWSConnection(); - // Get all user details getUserInformation(); @@ -102,8 +99,11 @@ async function runStartupFunctions() { // Start rotation of location dot startLocationDotRotation(); - // Get the stations and load them to the map - await getStations(); + // Start WebSocket connection and await the stations + startWSConnection(); + + // Load the stations into the map + loadStationMarkersFromArray(stationsArray); // Show any messages from EMEL await validateLogin();