Skip to content

Commit

Permalink
front: fix map marker offset
Browse files Browse the repository at this point in the history
Set the `offset` prop to define the image "hotspot" (ie, pixel
coordinate where the sign is planted on).

Signed-off-by: Simon Ser <[email protected]>
Closes: #9633
  • Loading branch information
emersion committed Dec 3, 2024
1 parent 08d9839 commit 7f31f82
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default function RenderItinerary({
'line-color': '#158DCF',
};

const markerOffset: [number, number] = [0, 8];

if (!pathItemsCoordinates || pathItemsCoordinates.length < 2) {
return null;
}
Expand All @@ -38,18 +40,34 @@ export default function RenderItinerary({

return (
<Source type="geojson" data={geojsonPath}>
<Marker longitude={originLongitude} latitude={originLatitude} anchor="bottom">
<Marker
longitude={originLongitude}
latitude={originLatitude}
anchor="bottom"
offset={markerOffset}
>
<img src={originIcon} alt="origin" />
</Marker>
{vias.map(([longitude, latitude], index) => (
<Marker key={`via-${index}`} longitude={longitude} latitude={latitude} anchor="bottom">
<Marker
key={`via-${index}`}
longitude={longitude}
latitude={latitude}
anchor="bottom"
offset={markerOffset}
>
<img src={viaIcon} alt={`via ${index + 1}`} />
<span className={cx('map-pathfinding-marker', 'via-number', 'stdcm-via')}>
{index + 1}
</span>
</Marker>
))}
<Marker longitude={destinationLongitude} latitude={destinationLatitude} anchor="bottom">
<Marker
longitude={destinationLongitude}
latitude={destinationLatitude}
anchor="bottom"
offset={markerOffset}
>
<img src={destinationIcon} alt="destination" />
</Marker>
<OrderedLayer
Expand Down

0 comments on commit 7f31f82

Please sign in to comment.