Skip to content

Commit e54f409

Browse files
Merge pull request #746 from opentripplanner/fix-stop-marker
Fix stop marker
2 parents 9de14e1 + 969836e commit e54f409

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

Diff for: lib/components/map/enhanced-stop-marker.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,23 @@ import { getModeFromStop, getStopName } from '../../util/viewer'
2020

2121
const { ViewStopButton } = StopsOverlayStyled
2222

23-
const getComplementaryColor = (color) =>
24-
color.isLight() ? color.darken(30) : color.lighten(40)
25-
26-
const caretPixels = 18
2723
const iconPixels = 32
2824
const iconPadding = 5
25+
const caretPixels = iconPixels / 2 + iconPadding
2926
const borderPixels = (props) => (props?.active ? 3 : 1)
30-
const caretMarginPixels = (props) =>
31-
(iconPixels - caretPixels - borderPixels(props)) / 2
27+
const leftPixels = (props) => caretPixels / 2 - borderPixels(props) / 2
28+
const bottomPixels = (props) =>
29+
-((caretPixels * 1.4142) / 4) - borderPixels(props) + iconPadding / 2
3230

3331
const DEFAULT_COLOR = '#a6a6a6'
32+
const strokeColor = (props) => (props?.active ? props.mainColor : DEFAULT_COLOR)
3433

3534
const BaseStopIcon = styled.div`
3635
background: #fff;
36+
border: ${borderPixels}px solid ${strokeColor};
3737
border-radius: 50%;
38-
border: ${borderPixels}px solid
39-
${(props) => (props?.active ? props.mainColor : DEFAULT_COLOR)};
40-
color: ${(props) => (props?.active ? props.mainColor : DEFAULT_COLOR)};
41-
fill: ${(props) => (props?.active ? props.mainColor : DEFAULT_COLOR)};
42-
font-size: ${iconPixels}px;
38+
fill: ${strokeColor};
4339
height: ${iconPixels}px;
44-
line-height: 1px;
4540
padding: ${iconPadding}px;
4641
position: relative;
4742
width: ${iconPixels}px;
@@ -55,19 +50,17 @@ const BaseStopIcon = styled.div`
5550
5651
&::after {
5752
background: #fff;
58-
border-bottom: ${borderPixels}px solid
59-
${(props) => (props?.active ? props.mainColor : DEFAULT_COLOR)};
60-
border-right: ${borderPixels}px solid
61-
${(props) => (props?.active ? props.mainColor : DEFAULT_COLOR)};
53+
border-bottom: ${borderPixels}px solid ${strokeColor};
54+
border-right: ${borderPixels}px solid ${strokeColor};
55+
bottom: ${bottomPixels}px;
56+
box-sizing: content-box;
6257
content: '';
6358
display: block;
6459
height: ${caretPixels}px;
60+
left: ${leftPixels}px;
61+
position: absolute;
6562
transform: rotate(45deg);
6663
width: ${caretPixels}px;
67-
68-
/* FIXME: figure out how these numbers can be calculated */
69-
margin-left: ${caretMarginPixels}px;
70-
margin-top: -${caretMarginPixels}px;
7164
}
7265
`
7366

@@ -128,7 +121,6 @@ class EnhancedStopMarker extends Component {
128121

129122
return (
130123
<MarkerWithPopup
131-
markerProps={{ anchor: 'top', offset: [1, -12] }}
132124
popupContents={
133125
activeStopId !== stop.id && (
134126
<BaseMapStyled.MapOverlayPopup>
@@ -179,8 +171,7 @@ const mapStateToProps = (state, ownProps) => {
179171
activeStopId: state.otp.ui.viewedStop?.stopId,
180172
highlight: highlightedStop === ownProps.stop.id,
181173
languageConfig: state.otp.config.language,
182-
modeColors,
183-
stop: ownProps.stop
174+
modeColors
184175
}
185176
}
186177

Diff for: lib/components/map/map.css

+15
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,18 @@
127127
.otp .map-overlay-popup .popup-row {
128128
margin-top: 6px;
129129
}
130+
131+
/*
132+
HACK: maplibre has a tendency to place the marker for the active stop in the stop viewer
133+
at the bottom of the map (i.e. first). This change puts the active stop on top so it is easier to see.
134+
*/
135+
.maplibregl-marker:first-of-type,
136+
.mapboxgl-marker:first-of-type {
137+
z-index: 100;
138+
}
139+
140+
/* Make sure popups stay on top of markers above. */
141+
.maplibregl-popup,
142+
.mapboxgl-popup {
143+
z-index: 101;
144+
}

0 commit comments

Comments
 (0)