chore(collections/map): reintroduce labels

This commit is contained in:
Elian Doran
2026-02-16 22:12:23 +02:00
parent 5c1c0efe0a
commit 49c0adb5d3
2 changed files with 17 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import { type GeoJSONSource } from "maplibre-gl";
import { AddLayerObject, type GeoJSONSource } from "maplibre-gl";
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
import FNote from "../../../entities/fnote";
@@ -15,9 +15,15 @@ export const MARKER_SVG = "foo"; // TODO: Fix
const iconSvgCache = new Map<string, string>();
const iconClassToBitmapCache = new Map<string, string | undefined>();
const LABEL_LAYOUT: Extract<AddLayerObject, { type: "symbol"}>["layout"] = {
"text-field": ["get", "name"],
"text-font": ["Open Sans Regular"],
"text-size": 12,
"text-anchor": "top",
"text-allow-overlap": true,
};
export default function Markers({ note }: { note: FNote }) {
const [ stylesLoaded, setStylesLoaded ] = useState(false);
export default function Markers({ note, hideLabels }: { note: FNote, hideLabels: boolean }) {
const map = useContext(ParentMap);
const childNotes = useChildNotes(note?.noteId);
@@ -42,7 +48,13 @@ export default function Markers({ note }: { note: FNote }) {
"icon-image": [ "get", "icon" ],
"icon-size": 1,
"icon-anchor": "bottom",
"icon-allow-overlap": true
"icon-allow-overlap": true,
...hideLabels ? [] : LABEL_LAYOUT
},
paint: {
"text-color": "#333",
"text-halo-color": "#fff",
"text-halo-width": 1,
}
});
});

View File

@@ -159,7 +159,7 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig }: ViewM
>
<Tooltips />
<ContextMenus note={note} isReadOnly={isReadOnly} />
<Markers note={note} />
<Markers note={note} hideLabels={hideLabels} />
</Map>}
<GeoMapTouchBar state={state} map={apiRef.current} />
</div>