Skip to content

Commit

Permalink
Address feedback v1
Browse files Browse the repository at this point in the history
  • Loading branch information
arindam1993 committed Feb 18, 2025
1 parent bda79d0 commit a44ec97
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/components/BikeHopperMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
CYCLE_TRACK_COLOR,
DEFAULT_BIKE_COLOR,
DEFAULT_INACTIVE_COLOR,
DEFAULT_PT_COLOR,
} from '../lib/colors';
import { RouteResponsePath, getApiPath } from '../lib/BikeHopperClient';
import classnames from 'classnames';
Expand Down Expand Up @@ -918,7 +919,7 @@ function getTransitTilesLineStyle(
['linear'],
0.3,
0.0,
['to-color', ['get', 'route_color']],
['to-color', ['get', 'route_color'], DEFAULT_PT_COLOR],
1.0,
['rgb', 255, 255, 255],
],
Expand Down Expand Up @@ -1037,22 +1038,37 @@ function getTransitTilesStopOutlineStyle(
function getTransitTilesStopNamesStyle(
activeStops: ActiveStops,
): Omit<SymbolLayerSpecification, 'source'> {
const isBus: ExpressionSpecification = ['to-boolean', ['get', 'bus']];

const notOnRouteAndIsBus: ExpressionSpecification = [
'all',
isBus,
['!', getIsActiveStopExpression(activeStops, ActiveStopTypes.onRoute)],
];

const textSizeExpr = (
onRouteSize: number,
offRouteSize: number,
): ExpressionSpecification => {
return [
'case',
getIsActiveStopExpression(activeStops, ActiveStopTypes.onRoute),
onRouteSize,
offRouteSize,
];
};

return {
id: 'routeStopNames',
'source-layer': 'stops',
type: 'symbol',
minzoom: 12,
filter: getIsActiveStopExpression(activeStops),
layout: {
'text-field': ['to-string', ['get', 'stop_name']],
'text-field': ['get', 'stop_name'],
'text-anchor': 'top-left',
'text-font': ['DIN Pro Medium', 'Arial Unicode MS Regular'],
'text-size': [
'case',
getIsActiveStopExpression(activeStops, ActiveStopTypes.onRoute),
14,
12,
],
'text-size': ['case', isBus, textSizeExpr(12, 10), textSizeExpr(14, 12)],
'text-justify': 'left',
'text-offset': [0.3, 0.3],
},
Expand All @@ -1065,6 +1081,19 @@ function getTransitTilesStopNamesStyle(
'black',
'gray',
],
'text-opacity': [
'interpolate',
['linear'],
['zoom'],
0,
['case', notOnRouteAndIsBus, 0, 1],
13.5,
['case', notOnRouteAndIsBus, 0, 1],
13.8,
['case', notOnRouteAndIsBus, 1, 1],
14,
['case', notOnRouteAndIsBus, 1, 1],
],
},
};
}
Expand Down

0 comments on commit a44ec97

Please sign in to comment.