-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathNeutralSections.tsx
68 lines (61 loc) · 1.74 KB
/
NeutralSections.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { isNil } from 'lodash';
import { type LayerProps, Source } from 'react-map-gl/maplibre';
import { useSelector } from 'react-redux';
import { MAP_URL } from 'common/Map/const';
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
import { getLayersSettings } from 'reducers/map/selectors';
import type { Theme } from 'types';
import NeutralSectionSigns from './NeutralSectionSigns';
type NeutralSectionsProps = {
colors: Theme;
layerOrder: number;
infraID: number | undefined;
overrideStore?: boolean;
};
const NeutralSectionsLayer = ({
colors,
layerOrder,
infraID,
overrideStore = false,
}: NeutralSectionsProps) => {
const layersSettings = useSelector(getLayersSettings);
const neutralSectionsParams: LayerProps = {
type: 'line',
'source-layer': 'neutral_sections',
minzoom: 5,
maxzoom: 24,
layout: {
visibility: 'visible',
'line-join': 'miter',
},
paint: {
'line-color': [
'case',
['==', ['get', 'lower_pantograph'], true],
colors.neutral_sections.lower_pantograph,
colors.neutral_sections.switch_off,
],
'line-width': 6,
'line-offset': 0,
'line-opacity': 0.5,
},
};
if ((!overrideStore && !layersSettings.neutral_sections) || isNil(infraID)) return null;
return (
<>
<Source
id="neutral_sections_geo"
type="vector"
url={`${MAP_URL}/layer/neutral_sections/mvt/geo/?infra=${infraID}`}
>
<OrderedLayer
{...neutralSectionsParams}
id="chartis/neutral_sections/geo"
layerOrder={layerOrder}
/>
</Source>
<NeutralSectionSigns colors={colors} layerOrder={layerOrder} infraID={infraID} />
</>
);
};
export default NeutralSectionsLayer;