-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front: move map markers computation in SimulationResultsMap
Signed-off-by: Clara Ni <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import cx from 'classnames'; | ||
import type { Position } from 'geojson'; | ||
import { Marker } from 'react-map-gl/maplibre'; | ||
|
||
import destinationIcon from 'assets/pictures/mapMarkers/destination.svg'; | ||
import viaIcon from 'assets/pictures/mapMarkers/intermediate-point.svg'; | ||
import originIcon from 'assets/pictures/mapMarkers/start.svg'; | ||
import { MARKER_TYPE } from 'modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap/ItineraryMarkers'; | ||
|
||
const MARKER_OFFSET: [number, number] = [0, 8]; | ||
|
||
export type MapMarker = { | ||
coordinates: Position; | ||
pointType: MARKER_TYPE; | ||
}; | ||
|
||
type MapMarkersProps = { | ||
markers: MapMarker[]; | ||
}; | ||
|
||
const MapMarkers = ({ markers }: MapMarkersProps) => | ||
markers.map(({ coordinates, pointType }, index) => { | ||
const viaNumber = markers[0].pointType === MARKER_TYPE.VIA ? index + 1 : index; | ||
let imgSrc = viaIcon; | ||
let imgAlt = `via ${viaNumber}`; | ||
|
||
if (pointType === MARKER_TYPE.ORIGIN) { | ||
imgSrc = originIcon; | ||
imgAlt = 'origin'; | ||
} else if (pointType === MARKER_TYPE.DESTINATION) { | ||
imgSrc = destinationIcon; | ||
imgAlt = 'destination'; | ||
} | ||
|
||
return ( | ||
<Marker | ||
longitude={coordinates[0]} | ||
latitude={coordinates[1]} | ||
anchor="bottom" | ||
offset={MARKER_OFFSET} | ||
> | ||
<img src={imgSrc} alt={imgAlt} /> | ||
{pointType === MARKER_TYPE.VIA && ( | ||
<span className={cx('map-pathfinding-marker', 'via-number', 'stdcm-via')}> | ||
{viaNumber} | ||
</span> | ||
)} | ||
</Marker> | ||
); | ||
}); | ||
|
||
export default MapMarkers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters