-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathRenderItinerary.tsx
48 lines (41 loc) · 1.54 KB
/
RenderItinerary.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { Feature, LineString } from 'geojson';
import { Marker, Source } from 'react-map-gl/maplibre';
import destinationIcon from 'assets/pictures/mapMarkers/destination.svg';
import originIcon from 'assets/pictures/mapMarkers/start.svg';
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
interface RenderItineraryProps {
geojsonPath: Feature<LineString>;
layerOrder: number;
}
export default function RenderItinerary(props: RenderItineraryProps) {
const { geojsonPath, layerOrder } = props;
const paintBackgroundLine = {
'line-width': 4,
'line-color': '#EDF9FF',
};
const paintLine = {
'line-width': 1,
'line-color': '#158DCF',
};
// We know we have a geometry so we have at least 2 coordinates
const [startLongitude, startLatitude] = geojsonPath.geometry.coordinates.at(0)!;
const [endLongitude, endLatitude] = geojsonPath.geometry.coordinates.at(-1)!;
return (
<Source type="geojson" data={geojsonPath}>
<Marker longitude={startLongitude} latitude={startLatitude} anchor="bottom">
<img src={originIcon} alt="origin" />
</Marker>
<OrderedLayer
id="geojsonPathBackgroundLine"
type="line"
paint={paintBackgroundLine}
beforeId="geojsonPathLine"
layerOrder={layerOrder}
/>
<OrderedLayer id="geojsonPathLine" type="line" paint={paintLine} layerOrder={layerOrder} />
<Marker longitude={endLongitude} latitude={endLatitude} anchor="bottom">
<img src={destinationIcon} alt="destination" />
</Marker>
</Source>
);
}