Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(geomap): draw marker titles the way the map draws its own labels
Elian Doran7668bf4c1fe9
diff --git a/apps/client/src/widgets/collections/geomap/Markers.tsx b/apps/client/src/widgets/collections/geomap/Markers.tsxindex 1a3d1a0f10..1c6aa07911 100644--- a/apps/client/src/widgets/collections/geomap/Markers.tsx+++ b/apps/client/src/widgets/collections/geomap/Markers.tsx@@ -44,7 +44,7 @@ const LABEL_LAYOUT: Extract<AddLayerObject, { type: "symbol" }>["layout"] = {* per note is what made that slow. The pin is rasterized once per colour and icon and handed to the* map as an image, which the layer then stamps on the GPU.*/-export default function Markers({ notes, hideLabels }: { notes: FNote[], hideLabels: boolean }) {+export default function Markers({ notes, hideLabels, isDarkTheme }: { notes: FNote[], hideLabels: boolean, isDarkTheme: boolean }) {const map = useContext(ParentMap);const version = useNoteChangeVersion(notes);@@ -100,9 +100,14 @@ export default function Markers({ notes, hideLabels }: { notes: FNote[], hideLab// element of its own wearing an `archived` class."icon-opacity": [ "case", [ "get", "archived" ], 0.5, 1 ],"text-opacity": [ "case", [ "get", "archived" ], 0.5, 1 ],- "text-color": "#333",- "text-halo-color": "#fff",- "text-halo-width": 1+ // A title is drawn the way the style draws its own place names: light+ // on the dark styles, and haloed by a soft, blurred glow rather than a+ // hard keyline. A crisp white outline stood out as a cut-out sticker on+ // any map, and on a dark one it was a white edge around dark text.+ "text-color": isDarkTheme ? "#fff" : "#333",+ "text-halo-color": isDarkTheme ? "rgba(0, 0, 0, 0.8)" : "rgba(255, 255, 255, 0.8)",+ "text-halo-width": 2,+ "text-halo-blur": 1}});}@@ -132,7 +137,7 @@ export default function Markers({ notes, hideLabels }: { notes: FNote[], hideLabmap.removeSource(MARKER_SOURCE);}};- }, [ map, notes, hideLabels, version ]);+ }, [ map, notes, hideLabels, isDarkTheme, version ]);return null;}diff --git a/apps/client/src/widgets/collections/geomap/index.css b/apps/client/src/widgets/collections/geomap/index.cssindex 7b095b3c30..6fe1c6197e 100644--- a/apps/client/src/widgets/collections/geomap/index.css+++ b/apps/client/src/widgets/collections/geomap/index.css@@ -68,11 +68,14 @@transform: translateX(-50%);font-size: 0.75rem;height: 1rem;- color: black;+ --label-halo: rgba(255, 255, 255, 0.8);+ color: #333;width: 100px;text-align: center;text-overflow: ellipsis;- text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;+ /* The soft glow the titles in the symbol layer are haloed with (see Markers), stacked because one+ blurred shadow alone is too faint to hold the text apart from a busy map. */+ text-shadow: 0 0 2px var(--label-halo), 0 0 2px var(--label-halo), 0 0 4px var(--label-halo);white-space: nowrap;overflow: hidden;}@@ -86,6 +89,6 @@ body[dir=rtl] .geo-map-container .geo-marker .title-label {}.geo-map-container.dark .geo-marker .title-label {+ --label-halo: rgba(0, 0, 0, 0.8);color: white;- text-shadow: -1px -1px 0 black, 1px -1px 0 black, -1px 1px 0 black, 1px 1px 0 black;}diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsxindex 734fd0e09e..2fbc1ec178 100644--- a/apps/client/src/widgets/collections/geomap/index.tsx+++ b/apps/client/src/widgets/collections/geomap/index.tsx@@ -174,7 +174,7 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig }: ViewM><Tooltips /><ContextMenus note={note} isReadOnly={isReadOnly} />- <Markers notes={notes} hideLabels={hideLabels} />+ <Markers notes={notes} hideLabels={hideLabels} isDarkTheme={layerData.isDarkTheme ?? false} />{notes.map(note => <NoteGpxTrackWrapper note={note} hideLabels={hideLabels} />)}</Map>}</div>