fix: corriger null paint et line-dasharray invalide dans cartoonizeStyle
This commit is contained in:
1
backend/public/assets/index-D676BouX.css
Normal file
1
backend/public/assets/index-D676BouX.css
Normal file
File diff suppressed because one or more lines are too long
9
backend/public/assets/index-DJWsPHf5.js
Normal file
9
backend/public/assets/index-DJWsPHf5.js
Normal file
File diff suppressed because one or more lines are too long
756
backend/public/assets/maplibre-gl-DrzcYKv3.js
Normal file
756
backend/public/assets/maplibre-gl-DrzcYKv3.js
Normal file
File diff suppressed because one or more lines are too long
@@ -8,8 +8,8 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Fredoka:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<script type="module" crossorigin src="/assets/index-Crs1I2FK.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-RGvCvNm_.css">
|
||||
<script type="module" crossorigin src="/assets/index-DJWsPHf5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D676BouX.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -13,6 +13,8 @@ function cartoonizeStyle(style) {
|
||||
const LAND_MID = '#5fb040', BEACH = '#f0e9b0';
|
||||
const ROAD_MAIN = '#f5c842', ROAD_SEC = '#f0e0a0';
|
||||
|
||||
const p = (layer) => layer.paint ?? {};
|
||||
|
||||
const layers = style.layers.map(layer => {
|
||||
const id = (layer.id || '').toLowerCase();
|
||||
const sl = (layer['source-layer'] || '').toLowerCase();
|
||||
@@ -26,22 +28,22 @@ function cartoonizeStyle(style) {
|
||||
id.includes('-water') || id.includes('ocean') || id.includes('lake')
|
||||
);
|
||||
if (isWaterFill) {
|
||||
return { ...layer, paint: { 'fill-color': OCEAN, 'fill-antialias': true, 'fill-opacity': 1 } };
|
||||
return { ...layer, paint: { 'fill-color': OCEAN, 'fill-opacity': 1 } };
|
||||
}
|
||||
|
||||
const isLandFill = layer.type === 'fill' && (
|
||||
id === 'earth' || id === 'land' || sl === 'earth' || id.includes('landmass')
|
||||
);
|
||||
if (isLandFill) return { ...layer, paint: { ...layer.paint, 'fill-color': LAND } };
|
||||
if (isLandFill) return { ...layer, paint: { ...p(layer), 'fill-color': LAND } };
|
||||
|
||||
const isGreenLanduse = layer.type === 'fill' && (
|
||||
id.includes('park') || id.includes('forest') || id.includes('wood') ||
|
||||
id.includes('national') || id.includes('grass') || id.includes('vegetation')
|
||||
);
|
||||
if (isGreenLanduse) return { ...layer, paint: { ...layer.paint, 'fill-color': LAND_MID, 'fill-opacity': 0.8 } };
|
||||
if (isGreenLanduse) return { ...layer, paint: { ...p(layer), 'fill-color': LAND_MID, 'fill-opacity': 0.8 } };
|
||||
|
||||
if (layer.type === 'fill' && (id.includes('beach') || id.includes('sand'))) {
|
||||
return { ...layer, paint: { ...layer.paint, 'fill-color': BEACH } };
|
||||
return { ...layer, paint: { ...p(layer), 'fill-color': BEACH } };
|
||||
}
|
||||
|
||||
const isCoastLine = layer.type === 'line' && (
|
||||
@@ -52,10 +54,10 @@ function cartoonizeStyle(style) {
|
||||
}
|
||||
|
||||
if (layer.type === 'line' && (id.includes('motorway') || id.includes('trunk') || id.includes('primary'))) {
|
||||
return { ...layer, paint: { ...layer.paint, 'line-color': ROAD_MAIN } };
|
||||
return { ...layer, paint: { ...p(layer), 'line-color': ROAD_MAIN } };
|
||||
}
|
||||
if (layer.type === 'line' && (id.includes('secondary') || id.includes('tertiary'))) {
|
||||
return { ...layer, paint: { ...layer.paint, 'line-color': ROAD_SEC } };
|
||||
return { ...layer, paint: { ...p(layer), 'line-color': ROAD_SEC } };
|
||||
}
|
||||
|
||||
return layer;
|
||||
@@ -89,7 +91,7 @@ const makeLayerStyles = (isPrediction, opacity) => ({
|
||||
'line-width': isPrediction ? 2 : 2.5,
|
||||
'line-opacity': opacity * 0.85,
|
||||
'line-opacity-transition': { duration: 350 },
|
||||
'line-dasharray': isPrediction ? [4, 3] : [1],
|
||||
...(isPrediction ? { 'line-dasharray': [4, 3] } : {}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user