Skip to content

Commit

Permalink
Merge pull request #118 from LACMTA/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
matikin9 authored Apr 3, 2024
2 parents 1d4970f + 4746cfd commit 8f45ec9
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,18 @@ function processVehicleData(data, features) {

function createNewMarker(vehicle, features) {
const existingMarker = markers[vehicle.properties.vehicle_id];

let routeCode = vehicle.properties.route_code;
let tripId = vehicle.properties.trip_id;
let isBus = false;

if (routeCode == '901' || routeCode == '910' || routeCode == '950') {
isBus = true;
}

// Check the route code and set the icon URL accordingly
let iconUrl = isBus ? 'bus.svg' : 'rail.svg';

if (existingMarker) {
// If it exists, remove the existing marker from the map
existingMarker.remove();
Expand All @@ -524,13 +536,9 @@ function createNewMarker(vehicle, features) {

const el = document.createElement('div');
el.className = 'marker';

// Check the route code and set the icon URL accordingly
let iconUrl = 'rail.svg';
let routeCode = vehicle.properties.route_code;
if (routeCode === '901' || routeCode === '910') {
iconUrl = 'bus.svg';
}
el.setAttribute('data-route', routeCode);
el.setAttribute('data-trip', tripId);
el.setAttribute('data-mode', isBus ? 'bus' : 'rail')

el.style.background = `url(${iconUrl}) no-repeat center/cover`;

Expand Down

0 comments on commit 8f45ec9

Please sign in to comment.