Skip to content

Commit 0243982

Browse files
committed
front: fix layers order on map
1 parent 7b37385 commit 0243982

File tree

6 files changed

+42
-19
lines changed

6 files changed

+42
-19
lines changed

front/src/applications/referenceMap/Map.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { CUSTOM_ATTRIBUTION } from 'common/Map/const';
4141
import LineSearchLayer from 'common/Map/Layers/LineSearchLayer';
4242

4343
import 'common/Map/Map.scss';
44+
import Buildings3d from 'common/Map/Layers/Buildings3d';
4445

4546
function Map() {
4647
const mapBlankStyle = useMapBlankStyle();
@@ -149,6 +150,8 @@ function Map() {
149150
/>
150151
</>
151152
)}
153+
<Buildings3d layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]} />
154+
152155
<Platforms
153156
colors={colors[mapStyle]}
154157
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}

front/src/assets/mapstyles/OSMStyle.json

-13
Original file line numberDiff line numberDiff line change
@@ -1040,19 +1040,6 @@
10401040
}
10411041
}
10421042
},
1043-
{
1044-
"id": "batiments_3d",
1045-
"source": "openmaptiles",
1046-
"source-layer": "building",
1047-
"type": "fill-extrusion",
1048-
"minzoom": 0,
1049-
"paint": {
1050-
"fill-extrusion-color": "#aaa",
1051-
"fill-extrusion-height": ["get", "render_height"],
1052-
"fill-extrusion-base": ["get", "render_min_height"],
1053-
"fill-extrusion-opacity": 0.6
1054-
}
1055-
},
10561043
{
10571044
"id": "admin_sub",
10581045
"type": "line",

front/src/common/Map/Consts/colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const colors: Record<string, Theme> = {
5656
halo: '#eee',
5757
},
5858
platform: {
59-
fill: '#e05206',
59+
fill: '#e9b996',
6060
},
6161
pn: {
6262
text: '#712b2b',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { Source, LayerProps } from 'react-map-gl/maplibre';
3+
4+
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
5+
import { OSM_URL } from 'common/Map/const';
6+
7+
type Buildings3dProps = {
8+
layerOrder?: number;
9+
};
10+
11+
function Buildings3d(props: Buildings3dProps) {
12+
const { layerOrder } = props;
13+
14+
const buildings3dParams: LayerProps = {
15+
id: 'batiments_3d',
16+
source: 'openmaptiles',
17+
'source-layer': 'building',
18+
type: 'fill-extrusion',
19+
minzoom: 0,
20+
paint: {
21+
'fill-extrusion-color': '#aaa',
22+
'fill-extrusion-height': ['get', 'render_height'],
23+
'fill-extrusion-base': ['get', 'render_min_height'],
24+
'fill-extrusion-opacity': 0.6,
25+
},
26+
};
27+
28+
return (
29+
<Source id="batiments" type="vector" url={OSM_URL} source-layer="building">
30+
<OrderedLayer {...buildings3dParams} layerOrder={layerOrder} />
31+
</Source>
32+
);
33+
}
34+
35+
export default Buildings3d;

front/src/common/Map/Layers/OrderedLayer.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function OrderedLayer(props: OrderedLayerProps) {
1111
const { layerOrder, ...restOfLayerProps } = props;
1212

1313
const layerProps = { ...restOfLayerProps };
14+
console.log('order : ', layerProps);
1415
if (isNumber(layerOrder) && map?.getLayer(`virtual-layer-${layerOrder}`)) {
1516
layerProps.beforeId = `virtual-layer-${layerOrder}`;
1617
}

front/src/common/Map/Layers/Platforms.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Platforms(props: PlatformsProps) {
1616

1717
const platformsParams: LayerProps = {
1818
id: 'osm/platforms',
19-
type: 'fill-extrusion',
19+
type: 'fill',
2020
source: 'openmaptiles',
2121
'source-layer': 'transportation',
2222
filter: [
@@ -26,10 +26,7 @@ function Platforms(props: PlatformsProps) {
2626
['==', 'subclass', 'platform'],
2727
],
2828
paint: {
29-
'fill-extrusion-color': colors.platform.fill,
30-
'fill-extrusion-height': 2,
31-
'fill-extrusion-base': 1,
32-
'fill-extrusion-opacity': 0.4,
29+
'fill-color': colors.platform.fill,
3330
},
3431
};
3532

0 commit comments

Comments
 (0)