Skip to content

Commit

Permalink
hide interchanges when stations are hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
the-nemz committed Mar 16, 2024
1 parent d9e0cc2 commit f977911
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ export function Map({ system,
[e.point.x + 6, e.point.y + 6]
];
// find features intersecting the bounding box.
const selectedFeatures = map.queryRenderedFeatures(bbox, {
layers: [ 'js-Map-stations' ]
});
const selectedFeatures = map.getLayer('js-Map-stations') ?
map.queryRenderedFeatures(bbox, { layers: [ 'js-Map-stations' ] }) :
[];

// select highest priority station in the returned features
let stationId;
Expand Down Expand Up @@ -938,10 +938,9 @@ export function Map({ system,
}
});
} catch (e) {
console.warn('animateVehicle error:', e);
continue;
}


// when vehicle has made it 100% of the way to the next station, calculate the next animation
if (vehicleValues.distance > vehicleValues.routeDistance) {
const currSection = vehicleValues.sections[vehicleValues.sectionIndex];
Expand Down Expand Up @@ -1403,7 +1402,7 @@ export function Map({ system,
let updatedInterchangeFeatures = {};
if (system.changing?.interchangeIds || system.changing?.all) {
for (const interchangeId of (system.changing.all ? Object.keys(interchanges) : system.changing.interchangeIds)) {
if (!(interchangeId in interchanges) || interchanges[interchangeId].stationIds.length <= 1) {
if (!pinsShown || !(interchangeId in interchanges) || interchanges[interchangeId].stationIds.length <= 1) {
updatedInterchangeFeatures[interchangeId] = {};
continue;
}
Expand Down Expand Up @@ -1477,7 +1476,7 @@ export function Map({ system,

const initialLinePaint = (layer, layerID, data, beforeLayerId) => {
// Initial paint of line
if (!map.getLayer(layerID)) {
if (styleLoaded && !map.getLayer(layerID)) {
let newLayer = JSON.parse(JSON.stringify(layer));
newLayer.id = layerID;
newLayer.source.data = data;
Expand Down

0 comments on commit f977911

Please sign in to comment.