fix: refine workbench map layers

This commit is contained in:
2026-08-26 15:26:41 +08:00
parent 2f2bd6cbf0
commit 3c5f39ed73
6 changed files with 100 additions and 13 deletions

View File

@@ -15,7 +15,6 @@ const geojson = new GeoJSON();
const source = () => new VectorSource();
export type LayerName =
| 'reference'
| 'gaodeReference'
| 'native'
| 'sidewalks'
| 'osm'
@@ -34,7 +33,6 @@ export function createLayers(onRoad: () => Road | null, scene: () => boolean) {
new Style({ fill: new Fill({ color: `${color}55` }), stroke: new Stroke({ color, width }) });
const layers: Record<LayerName, VectorLayer<VectorSource>> = {
reference: new VectorLayer({ source: source(), visible: false, style: simple('#8999a0') }),
gaodeReference: new VectorLayer({ source: source(), style: simple('#2563eb', 1.5) }),
native: new VectorLayer({
source: source(),
style: () => (scene() ? new Style({ fill: new Fill({ color: '#3f4b50' }) }) : simple('#296956')),
@@ -72,7 +70,15 @@ export function createLayers(onRoad: () => Road | null, scene: () => boolean) {
}),
centerLines: new VectorLayer({
source: source(),
style: new Style({ fill: new Fill({ color: '#f5be2a' }), stroke: new Stroke({ color: '#d29d16', width: 1 }) }),
style: (feature) => {
const white = feature.get('color') === 'white';
const color = white ? '#faf9ee' : '#f5be2a';
const solid = feature.get('pattern') === 'solid';
return new Style({
fill: new Fill({ color }),
stroke: new Stroke({ color: solid ? color : white ? '#aeb0aa' : '#d29d16', width: solid ? 0.25 : 0.8 }),
});
},
}),
controls: new VectorLayer({
source: source(),
@@ -126,7 +132,6 @@ export function updateLayers(layers: ReturnType<typeof createLayers>, state: Wor
target.addFeatures(features(value));
};
put('reference', state.layers.osm2streetsRoadSurface);
put('gaodeReference', state.junctionReference?.converted);
put('native', state.layers.nativeRoadSurface);
get('native').addFeatures(features(state.layers.nativeIntersectionSurface));
put('sidewalks', state.layers.nativeSidewalkSurface);