Skip to content

Build your personal knowledge base with Trilium Notes

feat(geomap): properties dialog with image map settings

Elian Doran9a8b10b7dd44
diff --git a/apps/client/src/translations/en-GB/translation.json b/apps/client/src/translations/en-GB/translation.json
index be6b17048c..4c7054e11e 100644
--- a/apps/client/src/translations/en-GB/translation.json
+++ b/apps/client/src/translations/en-GB/translation.json
@@ -248,5 +248,8 @@
},
"resource_download": {
"license": "{{license}} licence"
+ },
+ "geo-map": {
+ "dark-image-description": "Draws the marker titles in a light colour, so that they can be read over a dark image."
}
}
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ee12d98525..a4f087a68a 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3146,7 +3146,25 @@
"locate-error": "Couldn't find your location. Press again to stop looking.",
"locate-unavailable": "Your location isn't available",
"location-denied": "Location access was denied. Allow it for Trilium in your browser or system settings to show your location on the map.",
- "location-unavailable": "Your location couldn't be determined right now."
+ "location-unavailable": "Your location couldn't be determined right now.",
+ "properties": "Geo map properties...",
+ "properties-title": "Geo map properties",
+ "general": "General",
+ "image": "Image",
+ "image-description": "Draw the map over an image of your own instead of a world map, such as a floor plan or a fantasy map. Markers and shapes are then placed on the image.",
+ "image-note": "Image note",
+ "image-note-description": "A PNG, JPEG, WebP or GIF image. SVG images can't be used.",
+ "image-note-placeholder": "Search for an image note",
+ "image-too-large": "This image is {{width}} × {{height}} pixels. Some devices can't draw images larger than {{limit}} pixels on their longer side; the markers and shapes still appear there, but the image doesn't.",
+ "coordinates": "Coordinates",
+ "coordinates-description": "How positions on the image are measured: in its pixels from the top-left corner, or in coordinates of your own, such as the ones a video game uses.",
+ "coordinates-pixels": "Image pixels",
+ "coordinates-custom": "Custom",
+ "top-left-corner": "Top-left corner",
+ "bottom-right-corner": "Bottom-right corner",
+ "coordinates-invalid": "The two corners must differ in both x and y, so this change wasn't saved.",
+ "dark-image": "Dark image",
+ "dark-image-description": "Draws the marker titles in a light color, so that they can be read over a dark image."
},
"embedded_note": {
"open-note": "Open note",
diff --git a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
index b781444723..8cc5624e82 100644
--- a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
+++ b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
@@ -140,6 +140,7 @@ describe("CalendarProperties", () => {
"calendar_view.time_slots",
"calendar_view.slot_duration",
"calendar_view.slot_label_interval",
+ "book_properties_config.max-nesting-depth",
"book_properties.include_archived_notes"
]);
expect(general?.compareDocumentPosition(document.querySelector(".templates-stub") as Node))
diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.css b/apps/client/src/widgets/collections/geomap/GeoMapProperties.css
new file mode 100644
index 0000000000..2f9ba91aed
--- /dev/null
+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.css
@@ -0,0 +1,14 @@
+.modal.geo-map-properties-dialog {
+ .geo-map-corner input {
+ width: 8em;
+
+ & + input {
+ margin-inline-start: 0.5em;
+ }
+ }
+
+ .geo-map-image-notice,
+ .geo-map-coordinates-error {
+ margin: 0;
+ }
+}
diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx b/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx
new file mode 100644
index 0000000000..086cde5c54
--- /dev/null
+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx
@@ -0,0 +1,190 @@
+import { Modal as BootstrapModal } from "bootstrap";
+import { render } from "preact";
+import { act } from "preact/test-utils";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import type FNote from "../../../entities/fnote";
+import { buildNote } from "../../../test/easy-froca";
+import GeoMapProperties, { type GeoMapImageState } from "./GeoMapProperties";
+
+vi.mock("../../../services/i18n", () => ({
+ t: (key: string) => key
+}));
+// The settings dropdown's definitions translate through i18next directly, at import.
+vi.mock("i18next", async (importOriginal) => ({
+ ...await importOriginal<typeof import("i18next")>(),
+ t: (key: string) => key
+}));
+
+const mocks = vi.hoisted(() => ({
+ setLabel: vi.fn(async () => {}),
+ removeOwnedLabelByName: vi.fn(async () => {}),
+ setAttribute: vi.fn(async () => {})
+}));
+
+vi.mock("../../../services/attributes", () => ({
+ default: {
+ setLabel: mocks.setLabel,
+ removeOwnedLabelByName: mocks.removeOwnedLabelByName,
+ setAttribute: mocks.setAttribute,
+ isAffecting: () => true
+ }
+}));
+
+// NoteAutocomplete is tested in its own spec. A click on the stub picks `image2`.
+vi.mock("../../react/NoteAutocomplete", () => ({
+ default: ({ noteId, noteIdChanged }: {
+ noteId?: string, noteIdChanged: (noteId: string) => void
+ }) => (
+ <div
+ className="autocomplete-stub"
+ data-note-id={noteId ?? ""}
+ onClick={() => noteIdChanged("image2")}
+ />
+ )
+}));
+
+const LOADED_IMAGE: GeoMapImageState = { status: "image", size: { width: 2048, height: 1024 } };
+
+describe("GeoMapProperties", () => {
+ let container: HTMLElement;
+
+ function draw(labels: Record<string, string>, image: GeoMapImageState = { status: "geo" }) {
+ const note = buildNote({ title: "Map", ...labels }) as unknown as FNote;
+ act(() => {
+ render(<GeoMapProperties note={note} image={image} onClose={() => {}} />, container);
+ });
+ return note;
+ }
+
+ function query<T extends Element = HTMLElement>(selector: string) {
+ return document.querySelector<T>(`.geo-map-properties-dialog ${selector}`);
+ }
+
+ function optionTitles(selector: string) {
+ const titles = document.querySelectorAll(
+ `.geo-map-properties-dialog ${selector} .tn-card-option-title`);
+ return [ ...titles ].map((title) => title.textContent);
+ }
+
+ function cornerInputs() {
+ return [ ...document.querySelectorAll<HTMLInputElement>(
+ ".geo-map-properties-dialog .geo-map-corner input") ];
+ }
+
+ /** Types `value` into `input` and leaves it, which is when a number box commits. */
+ function commit(input: HTMLInputElement | undefined, value: string) {
+ if (!input) throw new Error("no such input");
+ act(() => {
+ input.value = value;
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ input.dispatchEvent(new Event("change"));
+ });
+ }
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ });
+
+ afterEach(() => {
+ render(null, container);
+ container.remove();
+
+ const modal = document.querySelector<HTMLElement>(".geo-map-properties-dialog");
+ if (modal) {
+ BootstrapModal.getInstance(modal)?.dispose();
+ modal.remove();
+ }
+
+ document.querySelector(".modal-backdrop")?.remove();
+ document.body.classList.remove("modal-open");
+ });
+
+ it("repeats the settings dropdown in a General card, minus the style of an image map", () => {
+ draw({});
+ expect(document.querySelector(".geo-map-properties-dialog .modal-title")?.textContent)
+ .toContain("geo-map.properties-title");
+ expect(optionTitles(".geo-map-properties-general")).toEqual([
+ "book_properties_config.map-style",
+ "book_properties_config.show-scale",
+ "book_properties_config.show-labels",
+ "book_properties_config.cluster-markers",
+ "book_properties_config.max-nesting-depth",
+ "book_properties.include_archived_notes"
+ ]);
+
+ render(null, container);
+ draw({ "~map:image": "image1" }, LOADED_IMAGE);
+ expect(optionTitles(".geo-map-properties-general"))
+ .not.toContain("book_properties_config.map-style");
+ });
+
+ it("offers only the image picker until the map has an image, and stores the one picked", () => {
+ const note = draw({});
+ expect(optionTitles(".geo-map-properties-image")).toEqual([ "geo-map.image-note" ]);
+
+ act(() => query(".autocomplete-stub")?.click());
+ expect(mocks.setAttribute).toHaveBeenCalledWith(note, "relation", "map:image", "image2");
+ });
+
+ it("measures in pixels until custom corners are chosen, starting them at the size", () => {
+ const note = draw({ "~map:image": "image1" }, LOADED_IMAGE);
+ expect(query(".autocomplete-stub")?.dataset.noteId).toBe("image1");
+ expect(optionTitles(".geo-map-properties-image")).toEqual([
+ "geo-map.image-note", "geo-map.coordinates", "geo-map.dark-image"
+ ]);
+ expect(cornerInputs()).toHaveLength(0);
+
+ const mode = query<HTMLSelectElement>(".geo-map-coordinates select");
+ expect(mode?.value).toBe("pixels");
+ act(() => {
+ if (!mode) return;
+ mode.value = "custom";
+ mode.dispatchEvent(new Event("change"));
+ });
+ expect(mocks.setLabel)
+ .toHaveBeenCalledWith(note.noteId, "map:imageBounds", "0,0 2048,1024");
+ });
+
+ it("stores corners once they span the image, and removes them to return to pixels", () => {
+ const note = draw(
+ { "~map:image": "image1", "#map:imageBounds": "-512,512 512,-512" }, LOADED_IMAGE);
+ const inputs = cornerInputs();
+ expect(inputs.map((input) => input.value)).toEqual([ "-512", "512", "512", "-512" ]);
+
+ // A right edge on the left one spans nothing, so it is held back and explained.
+ commit(inputs[2], "-512");
+ expect(mocks.setLabel).not.toHaveBeenCalled();
+ expect(query(".geo-map-coordinates-error")?.textContent)
+ .toBe("geo-map.coordinates-invalid");
+
+ commit(inputs[2], "1024.5");
+ expect(mocks.setLabel)
+ .toHaveBeenCalledWith(note.noteId, "map:imageBounds", "-512,512 1024.5,-512");
+ expect(query(".geo-map-coordinates-error")).toBeNull();
+
+ const mode = query<HTMLSelectElement>(".geo-map-coordinates select");
+ expect(mode?.value).toBe("custom");
+ act(() => {
+ if (!mode) return;
+ mode.value = "pixels";
+ mode.dispatchEvent(new Event("change"));
+ });
+ expect(mocks.removeOwnedLabelByName).toHaveBeenCalledWith(note, "map:imageBounds");
+ });
+
+ it("says why an image cannot be drawn, or might not be on every device", () => {
+ draw({ "~map:image": "image1" }, { status: "error", reason: "svg" });
+ expect(query(".geo-map-image-notice")?.textContent).toBe("geo-map.image-svg-unsupported");
+
+ render(null, container);
+ draw({ "~map:image": "image1" }, { status: "image", size: { width: 8192, height: 2048 } });
+ expect(query(".geo-map-image-notice")?.textContent).toBe("geo-map.image-too-large");
+
+ render(null, container);
+ draw({ "~map:image": "image1" }, LOADED_IMAGE);
+ expect(query(".geo-map-image-notice")).toBeNull();
+ });
+});
diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx b/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx
new file mode 100644
index 0000000000..1ed4fe89d8
--- /dev/null
+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx
@@ -0,0 +1,246 @@
+import "./GeoMapProperties.css";
+
+import { useEffect, useState } from "preact/hooks";
+
+import type FNote from "../../../entities/fnote";
+import { t } from "../../../services/i18n";
+import {
+ CollectionPropertiesDialog, INCLUDE_ARCHIVED_PROPERTY
+} from "../../note_bars/CollectionProperties";
+import { bookPropertiesConfig } from "../../note_bars/collection-properties-config";
+import Admonition from "../../react/Admonition";
+import { Card, CardSection, OptionCardSection } from "../../react/Card";
+import FormSelect from "../../react/FormSelect";
+import FormTextBox from "../../react/FormTextBox";
+import FormToggle from "../../react/FormToggle";
+import { useNoteLabel, useNoteLabelBoolean, useNoteRelation } from "../../react/hooks";
+import NoteAutocomplete from "../../react/NoteAutocomplete";
+import { isPropertyVisible, ViewPropertySection } from "../../react/NotePropertyMenu";
+import { formatImageExtent, type ImageSize, parseImageExtent } from "./space";
+
+/** What the map knows of its image: none, loading, unusable, or loaded at its natural size. */
+export type GeoMapImageState =
+ | { status: "geo" | "loading" }
+ | { status: "error"; reason: "unloadable" | "svg" }
+ | { status: "image"; size: ImageSize };
+
+/** The longest side, in pixels, that practically every graphics card can draw an image at. */
+const SAFE_IMAGE_SIDE = 4096;
+
+/**
+ * The geo map's settings: those of the collection's settings dropdown, and the image an image map
+ * is drawn over, which only this dialog holds.
+ */
+export default function GeoMapProperties({ note, image, onClose }: {
+ note: FNote;
+ image: GeoMapImageState;
+ onClose: () => void;
+}) {
+ // Read here so that the General card hides the map style as soon as an image is picked.
+ useNoteRelation(note, "map:image");
+
+ return (
+ <CollectionPropertiesDialog
+ className="geo-map-properties-dialog"
+ title={t("geo-map.properties-title")}
+ show
+ onHidden={onClose}
+ >
+ <Card className="geo-map-properties-general" heading={t("geo-map.general")}>
+ {GENERAL_PROPERTIES
+ .filter((property) => isPropertyVisible(property, note))
+ .map((property, index) => (
+ <ViewPropertySection key={index} note={note} property={property} />
+ ))}
+ </Card>
+
+ <ImageCard note={note} image={image} />
+ </CollectionPropertiesDialog>
+ );
+}
+
+/** What the settings dropdown offers for a geo map, which the General card repeats. */
+const GENERAL_PROPERTIES = [
+ ...bookPropertiesConfig.geoMap.properties, INCLUDE_ARCHIVED_PROPERTY
+];
+
+function ImageCard({ note, image }: { note: FNote; image: GeoMapImageState }) {
+ const [ imageNoteId, setImageNoteId ] = useNoteRelation(note, "map:image");
+ const [ isDarkImage, setDarkImage ] = useNoteLabelBoolean(note, "map:darkStyle");
+ const notice = imageNotice(image);
+
+ return (
+ <Card
+ className="geo-map-properties-image"
+ heading={t("geo-map.image")}
+ description={t("geo-map.image-description")}
+ >
+ <OptionCardSection
+ label={t("geo-map.image-note")}
+ description={t("geo-map.image-note-description")}
+ stacked
+ >
+ <NoteAutocomplete
+ noteId={imageNoteId ?? undefined}
+ placeholder={t("geo-map.image-note-placeholder")}
+ noteIdChanged={setImageNoteId}
+ />
+ </OptionCardSection>
+
+ {imageNoteId && notice && (
+ <CardSection>
+ <Admonition type={notice.type} className="geo-map-image-notice">
+ {notice.text}
+ </Admonition>
+ </CardSection>
+ )}
+
+ {imageNoteId && <>
+ <ImageCoordinates
+ note={note}
+ size={image.status === "image" ? image.size : undefined}
+ />
+ <OptionCardSection
+ name="geo-map-dark-image"
+ label={t("geo-map.dark-image")}
+ description={t("geo-map.dark-image-description")}
+ >
+ <FormToggle currentValue={isDarkImage} onChange={setDarkImage} />
+ </OptionCardSection>
+ </>}
+ </Card>
+ );
+}
+
+/**
+ * Whether positions are measured in the image's pixels or in coordinates of the map's own, and the
+ * corners those coordinates give the image (`#map:imageBounds`).
+ */
+function ImageCoordinates({ note, size }: { note: FNote; size: ImageSize | undefined }) {
+ const [ boundsValue, setBoundsValue ] = useNoteLabel(note, "map:imageBounds");
+ const isCustom = boundsValue !== null && boundsValue !== undefined;
+ const [ corners, setCorners ] = useState(() => cornersOf(boundsValue));
+ const [ isInvalid, setInvalid ] = useState(false);
+
+ useEffect(() => {
+ setCorners(cornersOf(boundsValue));
+ setInvalid(false);
+ }, [ boundsValue ]);
+
+ function changeMode(mode: string) {
+ if (mode === "custom") {
+ // Starts from the pixels, so that switching leaves every marker where it is.
+ setBoundsValue(formatImageExtent({
+ topLeft: [ 0, 0 ],
+ bottomRight: [ size?.width ?? 100, size?.height ?? 100 ]
+ }));
+ } else {
+ setBoundsValue(null);
+ }
+ }
+
+ function commitCorner(index: number, value: string) {
+ const next = [ ...corners ];
+ next[index] = value;
+ setCorners(next);
+
+ const extent = parseImageExtent(`${next[0]},${next[1]} ${next[2]},${next[3]}`);
+ setInvalid(!extent);
+ if (extent) {
+ setBoundsValue(formatImageExtent(extent));
+ }
+ }
+
+ return (
+ <OptionCardSection
+ className="geo-map-coordinates"
+ name="geo-map-coordinates"
+ label={t("geo-map.coordinates")}
+ description={t("geo-map.coordinates-description")}
+ subSectionsVisible
+ subSections={isCustom ? <>
+ <CornerSection
+ label={t("geo-map.top-left-corner")}
+ x={corners[0]} y={corners[1]}
+ onCommit={commitCorner}
+ />
+ <CornerSection
+ label={t("geo-map.bottom-right-corner")}
+ x={corners[2]} y={corners[3]}
+ onCommit={(axis, value) => commitCorner(2 + axis, value)}
+ />
+ {isInvalid && (
+ <CardSection>
+ <Admonition type="caution" className="geo-map-coordinates-error">
+ {t("geo-map.coordinates-invalid")}
+ </Admonition>
+ </CardSection>
+ )}
+ </> : undefined}
+ >
+ <FormSelect
+ values={[
+ { value: "pixels", title: t("geo-map.coordinates-pixels") },
+ { value: "custom", title: t("geo-map.coordinates-custom") }
+ ]}
+ keyProperty="value"
+ titleProperty="title"
+ currentValue={isCustom ? "custom" : "pixels"}
+ onChange={changeMode}
+ />
+ </OptionCardSection>
+ );
+}
+
+/** One corner of the image, as an `x` and a `y` committed when either box is left. */
+function CornerSection({ label, x, y, onCommit }: {
+ label: string;
+ x: string;
+ y: string;
+ /** Called with 0 for `x` and 1 for `y`. */
+ onCommit: (axis: 0 | 1, value: string) => void;
+}) {
+ return (
+ <OptionCardSection className="geo-map-corner" label={label}>
+ <FormTextBox
+ type="number" step="any" placeholder="x" aria-label={`${label} x`}
+ currentValue={x} onBlur={(value) => onCommit(0, value)}
+ />
+ <FormTextBox
+ type="number" step="any" placeholder="y" aria-label={`${label} y`}
+ currentValue={y} onBlur={(value) => onCommit(1, value)}
+ />
+ </OptionCardSection>
+ );
+}
+
+/** The four numbers of a `#map:imageBounds` value, empty where it names no corners. */
+function cornersOf(value: string | null | undefined): string[] {
+ const extent = parseImageExtent(value);
+ return extent ? [ ...extent.topLeft, ...extent.bottomRight ].map(String) : [ "", "", "", "" ];
+}
+
+interface ImageNotice {
+ type: "caution" | "warning";
+ text: string;
+}
+
+/** What the dialog says about an image that cannot be drawn, or might not be on every device. */
+function imageNotice(image: GeoMapImageState): ImageNotice | null {
+ if (image.status === "error") {
+ return {
+ type: "caution",
+ text: t(image.reason === "svg"
+ ? "geo-map.image-svg-unsupported"
+ : "geo-map.image-unavailable")
+ };
+ }
+ if (image.status !== "image") return null;
+
+ const { width, height } = image.size;
+ if (Math.max(width, height) <= SAFE_IMAGE_SIDE) return null;
+ return {
+ type: "warning",
+ text: t("geo-map.image-too-large", { width, height, limit: SAFE_IMAGE_SIDE })
+ };
+}
diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsx
index 4bb8e12d67..c23354ecd6 100644
--- a/apps/client/src/widgets/collections/geomap/index.tsx
+++ b/apps/client/src/widgets/collections/geomap/index.tsx
@@ -1,6 +1,8 @@
import "./index.css";
import type { Map as MapLibreGLMap } from "maplibre-gl";
+import { createPortal } from "preact";
+import { lazy, Suspense } from "preact/compat";
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
import FNote from "../../../entities/fnote";
@@ -13,6 +15,7 @@ import toast from "../../../services/toast";
import { fileAccept } from "../../../services/utils";
import { logError } from "../../../services/ws";
import CollectionProperties from "../../note_bars/CollectionProperties";
+import { FormListItem } from "../../react/FormList";
import { useCollectionTreeDrag, useColorScheme, useEffectiveReadOnly, useNoteBlob, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteLabelByName, useNoteProperty, useNoteRelation, useSpacedUpdate, useTriliumEvent } from "../../react/hooks";
import NoItems from "../../react/NoItems";
import { ViewModeProps } from "../interface";
@@ -133,6 +136,14 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig, onOpenN
const image = imageMap.status === "image" ? imageMap : undefined;
const space = image?.space ?? geoSpace;
const isGeo = space.kind === "geo";
+ const [ isEditingProperties, setIsEditingProperties ] = useState(false);
+
+ // The note actions menu offers the properties dialog, which lives here rather than in the menu.
+ useTriliumEvent("showCollectionProperties", ({ ntxId }) => {
+ if (ntxId === noteContext?.ntxId && !isReadOnly) {
+ setIsEditingProperties(true);
+ }
+ });
const viewKey = isGeo ? "view" : "imageView";
const savedView = viewConfig?.[viewKey];
const layerData = useLayerData(note, image);
@@ -425,7 +436,14 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig, onOpenN
{/* Nothing of its own at the end: locking is the read-only badge's, and adding a note
lives on the map itself (see EditToolbar), where it survives the map going
fullscreen without this bar. */}
- <CollectionProperties note={note} />
+ <CollectionProperties
+ note={note}
+ optionsChildren={!isReadOnly && (
+ <FormListItem icon="bx bx-cog" onClick={() => setIsEditingProperties(true)}>
+ {t("geo-map.properties")}
+ </FormListItem>
+ )}
+ />
{imageMap.status === "error" && <NoItems
icon="bx bx-image-alt"
text={t(imageMap.reason === "svg" ? "geo-map.image-svg-unsupported" : "geo-map.image-unavailable")}
@@ -515,10 +533,25 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig, onOpenN
<ShapeNames />
<FitToNotes notes={notes} enabled={!savedView} bounds={image?.space.bounds} />
</Map></MapSpaceContext.Provider>}
+ {isEditingProperties && createPortal(
+ <Suspense fallback={null}>
+ <GeoMapProperties
+ note={note}
+ image={imageMap.status === "image"
+ ? { status: "image", size: imageMap.space.size }
+ : imageMap}
+ onClose={() => setIsEditingProperties(false)}
+ />
+ </Suspense>,
+ document.body
+ )}
</div>
);
}
+/** Loaded when the properties dialog is first opened. */
+const GeoMapProperties = lazy(() => import("./GeoMapProperties"));
+
/**
* Rounds a coordinate to six decimals, the precision a place is named and stored at (see
* `formatLocation` in Markers). A geolocation fix reports far more digits than that.
diff --git a/apps/client/src/widgets/collections/geomap/space.spec.ts b/apps/client/src/widgets/collections/geomap/space.spec.ts
index d6ca7f2606..dcc638b068 100644
--- a/apps/client/src/widgets/collections/geomap/space.spec.ts
+++ b/apps/client/src/widgets/collections/geomap/space.spec.ts
@@ -2,7 +2,7 @@ import { MercatorCoordinate } from "maplibre-gl";
import { describe, expect, it } from "vitest";
import { buildNote } from "../../../test/easy-froca";
-import { geoSpace, imageSpace, isShapeNote, locationOf, parseImageExtent, shapeOf } from "./space";
+import { formatImageExtent, geoSpace, type ImageExtent, imageSpace, isShapeNote, locationOf, parseImageExtent, shapeOf } from "./space";
describe("geoSpace", () => {
it("stores latitude first and hands MapLibre longitude first", () => {
@@ -148,6 +148,12 @@ describe("imageSpace with named corners", () => {
expect(parseImageExtent(value)).toBeNull();
}
});
+
+ it("writes corners in the form it reads them", () => {
+ const extent = { topLeft: [ -512.5, 1000 ], bottomRight: [ 512, -1000 ] } as ImageExtent;
+ expect(formatImageExtent(extent)).toBe("-512.5,1000 512,-1000");
+ expect(parseImageExtent(formatImageExtent(extent))).toEqual(extent);
+ });
});
function shapeOrThrow<T>(shape: T | null): T {
diff --git a/apps/client/src/widgets/collections/geomap/space.ts b/apps/client/src/widgets/collections/geomap/space.ts
index eee911a330..c8fbbc628d 100644
--- a/apps/client/src/widgets/collections/geomap/space.ts
+++ b/apps/client/src/widgets/collections/geomap/space.ts
@@ -306,6 +306,11 @@ export function parseImageExtent(value: string | null | undefined): ImageExtent
return { topLeft, bottomRight };
}
+/** `extent` as a `#map:imageBounds` value, the form {@link parseImageExtent} reads. */
+export function formatImageExtent({ topLeft, bottomRight }: ImageExtent) {
+ return `${topLeft[0]},${topLeft[1]} ${bottomRight[0]},${bottomRight[1]}`;
+}
+
/** `x,y` as an image label stores it, or `null` if unreadable. */
function parsePair(value: string | null | undefined): [number, number] | null {
if (!value) return null;
diff --git a/apps/client/src/widgets/layout/NoteActions.tsx b/apps/client/src/widgets/layout/NoteActions.tsx
index ee49c6307f..b3f7fffca6 100644
--- a/apps/client/src/widgets/layout/NoteActions.tsx
+++ b/apps/client/src/widgets/layout/NoteActions.tsx
@@ -84,6 +84,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "spreadsheet", "llmChat"].includes(noteType) || note.isSvg();
const isSearchOrBook = ["search", "book"].includes(noteType);
const isBoard = noteType === "book" && viewType === "board";
+ const isGeoMap = noteType === "book" && viewType === "geoMap";
// A calendar root makes day notes rather than events, so it has no templates to configure.
const isEventCalendar = noteType === "book" && viewType === "calendar"
&& !note.hasLabel("calendarRoot") && !note.hasLabel("workspaceCalendarRoot");
@@ -177,8 +178,9 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
{note.type === "render" && <CommandItem command="renderActiveNote" icon="bx bx-extension" text={t("note_actions.re_render_note")}
/>}
- {(isBoard || isEventCalendar) && <CommandItem icon="bx bx-cog"
- text={isBoard ? t("board_view.properties") : t("calendar_view.properties")}
+ {(isBoard || isEventCalendar || isGeoMap) && <CommandItem icon="bx bx-cog"
+ text={isBoard ? t("board_view.properties")
+ : isGeoMap ? t("geo-map.properties") : t("calendar_view.properties")}
command={() => parentComponent?.triggerEvent("showCollectionProperties", { ntxId: noteContext?.ntxId })} />}
<FormDropdownSubmenu icon="bx bx-wrench" title={t("note_actions.advanced")}>
diff --git a/apps/client/src/widgets/note_bars/collection-properties-config.tsx b/apps/client/src/widgets/note_bars/collection-properties-config.tsx
index d170083beb..7a27118286 100644
--- a/apps/client/src/widgets/note_bars/collection-properties-config.tsx
+++ b/apps/client/src/widgets/note_bars/collection-properties-config.tsx
@@ -102,6 +102,8 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
type: "combobox",
bindToLabel: "map:style",
defaultValue: DEFAULT_MAP_LAYER_NAME,
+ // An image map is drawn over its image instead.
+ isVisible: (note) => !note.getRelationValue("map:image"),
options: [
{
title: t("book_properties_config.raster"),
diff --git a/apps/client/src/widgets/react/NotePropertyMenu.tsx b/apps/client/src/widgets/react/NotePropertyMenu.tsx
index cb4a3624b3..d53db5fb3b 100644
--- a/apps/client/src/widgets/react/NotePropertyMenu.tsx
+++ b/apps/client/src/widgets/react/NotePropertyMenu.tsx
@@ -7,7 +7,7 @@ import FNote from "../../entities/fnote";
import NoteContextAwareWidget from "../note_context_aware_widget";
import { OptionCardSection } from "./Card";
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "./FormList";
-import FormSelect from "./FormSelect";
+import FormSelect, { FormSelectWithGroups } from "./FormSelect";
import FormToggle from "./FormToggle";
import HelpTooltipButton from "./HelpTooltipButton";
import FormTextBox from "./FormTextBox";
@@ -88,6 +88,8 @@ export interface ComboBoxProperty {
*/
defaultValue?: string;
options: (ComboBoxItem | Separator | ComboBoxGroup)[];
+ /** When provided, the property is only rendered if this returns true for the current note. */
+ isVisible?: (note: FNote) => boolean;
}
export interface SubmenuProperty {
@@ -155,15 +157,19 @@ export function ViewProperty({ note, property }: { note: FNote, property: BookPr
/**
* A property as a row of a settings card, for a dialog that offers what the collection's settings
- * dropdown does. Covers switches, option groups and the submenus holding them; buttons and the
- * other kinds that only make sense in a menu render nothing.
+ * dropdown does. Covers switches, numbers, option groups, comboboxes and the submenus holding them;
+ * buttons and the other kinds that only make sense in a menu render nothing.
*/
export function ViewPropertySection({ note, property }: { note: FNote, property: BookProperty }) {
switch (property.type) {
case "checkbox":
return <CheckBoxPropertySection note={note} property={property} />;
+ case "number":
+ return <NumberPropertySection note={note} property={property} />;
case "option-group":
return <OptionGroupPropertySection note={note} property={property} />;
+ case "combobox":
+ return <ComboBoxPropertySection note={note} property={property} />;
case "submenu":
return (
<OptionCardSection
@@ -372,3 +378,47 @@ function OptionGroupPropertySection({ note, property }: {
</OptionCardSection>
);
}
+
+function NumberPropertySection({ note, property }: { note: FNote, property: NumberProperty & PropertyHelp }) {
+ //@ts-expect-error Interop with text box which takes in string values even for numbers.
+ const [ value, setValue ] = useNoteLabel(note, property.bindToLabel);
+ return (
+ <OptionCardSection
+ name={property.bindToLabel}
+ label={property.label}
+ description={property.helpTooltip}
+ >
+ <FormTextBox
+ type="number"
+ currentValue={value ?? ""}
+ onChange={setValue}
+ min={property.min ?? 0}
+ disabled={property.disabled?.(note)}
+ />
+ </OptionCardSection>
+ );
+}
+
+/** A combobox as a select, its groups as option groups; a separator has nothing to show there. */
+function ComboBoxPropertySection({ note, property }: {
+ note: FNote, property: ComboBoxProperty & PropertyHelp
+}) {
+ const [ value, setValue ] = useNoteLabel(note, property.bindToLabel);
+ const values = property.options.filter(
+ (option): option is ComboBoxItem | ComboBoxGroup => !("type" in option));
+ return (
+ <OptionCardSection
+ name={property.bindToLabel}
+ label={property.label}
+ description={property.helpTooltip}
+ >
+ <FormSelectWithGroups<ComboBoxItem>
+ values={values}
+ keyProperty="value"
+ titleProperty="label"
+ currentValue={value ?? property.defaultValue ?? undefined}
+ onChange={setValue}
+ />
+ </OptionCardSection>
+ );
+}
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html
index ed067bd6d0..b0d41edf4f 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html
@@ -156,6 +156,9 @@
<li><span class="tn-icon bx bx-cog"></span><em>Calendar properties</em> appears
on a&nbsp;<a class="reference-link" href="#root/_help_xWbu3jpNWapp">Calendar</a> that
creates events, and configures its event templates.</li>
+ <li><span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> appears
+ on a&nbsp;<a class="reference-link" href="#root/_help_81SGnPGMk7Xc">Geo Map</a>,
+ and configures its map settings and the image of an <a href="#root/_help_ZRDXGc0nAIh4">image map</a>.</li>
</ul>
<h2>Advanced</h2>
<p>The <span class="tn-icon bx bx-wrench"></span><em>Advanced</em> submenu
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html
index 916a1c32f3..da35524b75 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html
@@ -154,6 +154,8 @@
<li>Set the slot duration (the length of each time row in day/week view).</li>
<li>Set the slot label interval (how often time labels appear on the axis
in day/week view).</li>
+ <li>Limit how deep below the calendar events are looked for, with <em>Max nesting depth</em> (see <a
+ href="#limiting-the-depth">below</a>).</li>
</ul>
<p>The same settings, together with whether archived notes are shown, are
also listed under <em>General</em> in the <span class="tn-icon bx bx-cog"></span> <em>Calendar properties</em> dialog
@@ -430,6 +432,12 @@ class="table">
<p>When not used in a Journal, the calendar is recursive. That is, it will
look for events not just in its child notes but also in the children of
these child notes.</p>
+<h3>Limiting the depth</h3>
+<p>To limit how deep the calendar looks for events, set <em>Max nesting depth</em> in
+ the&nbsp;<a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>,
+ or the <code>#maxNestingDepth</code> label: <code>0</code> shows only the child
+ notes, <code>1</code> adds their children, and so on. Without a value, events
+ are looked for at every level. The setting doesn't apply in a Journal.</p>
<h2>Recurrence</h2>
<p>The built in calendar view also supports repeating tasks (e.g. every week,
every month as well as more complex recurrency rules).</p>
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
index b39a553bee..72d9f5ad1e 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
@@ -587,4 +587,13 @@ class="admonition note">
markers that make up the cluster are now visible.</li>
</ul>
</li>
-</ul>
\ No newline at end of file
+ <li>The map shows the notes of its whole subtree, not only its children. <em>Max nesting depth</em> (<code>#maxNestingDepth</code>)
+ limits how deep below the map it looks: <code>0</code> shows only the children, <code>1</code> adds
+ their children, and so on. Without a value, every level is shown.</li>
+</ul>
+<p>The same options, together with whether archived notes are shown, are
+ also listed under <em>General</em> in the <span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> dialog,
+ opened from the&nbsp;<a class="reference-link" href="#root/_help_8YBEPzcpUgxw">Note menu</a> or
+ from the settings menu of the&nbsp;<a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>.
+ Its <em>Image</em> section draws the map over an image of your own instead,
+ as described in&nbsp;<a class="reference-link" href="#root/_help_ZRDXGc0nAIh4">Image maps</a>.</p>
\ No newline at end of file
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map/Image maps.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map/Image maps.html
index 358032e8c0..c93c92a349 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map/Image maps.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map/Image maps.html
@@ -10,11 +10,15 @@
into the note tree. PNG, JPEG, WebP and GIF images are supported; SVG images
are not.</li>
<li>Create a geo map, or open an existing one.</li>
- <li>In the attributes of the geo map, add a <code>~map:image</code> <a href="#root/_help_Cq5X6iKQop6R">relation</a> pointing
- to the image note.</li>
+ <li>Open the <span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> dialog
+ from the&nbsp;<a class="reference-link" href="#root/_help_8YBEPzcpUgxw">Note menu</a> or
+ from the settings menu of the&nbsp;<a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>.</li>
+ <li>Under <em>Image</em>, choose the image note in <em>Image note</em>.</li>
</ol>
<p>The map then shows the image instead of the world map and opens with the
- whole image in view. To go back to a world map, remove the relation.</p>
+ whole image in view. To go back to a world map, clear <em>Image note</em>.</p>
+<p>The image note is stored in a <code>~map:image</code> <a href="#root/_help_Cq5X6iKQop6R">relation</a> of
+ the geo map, which can also be added by hand.</p>
<h2>Image size</h2>
<p>Images are resized when they are uploaded, so by default the image of
a map is at most 2000 pixels on its longer side, which can be too coarse
@@ -31,7 +35,9 @@
how large it can be. Images up to 4096 pixels on their longer side are
safe on practically every device, and most computers handle up to 16384
pixels. On a device whose graphics card cannot hold the image, the markers
- and shapes still appear but the image itself does not.</p>
+ and shapes still appear but the image itself does not. The <em>Geo map properties</em> dialog
+ warns about an image larger than 4096 pixels, and about one that can't
+ be used at all, such as an SVG image.</p>
<h2>Interaction</h2>
<p>Adding, moving and removing markers, drawing shapes, the popup view and
the contextual menu work as described for the&nbsp;<a class="reference-link"
@@ -48,18 +54,24 @@
<li>Opening a location in an external map application.</li>
</ul>
<p>The look of the marker titles follows the image: if the image is dark,
- add the <code>#map:darkStyle</code> label to the geo map so that the titles
- are drawn in a light color.</p>
+ turn on <em>Dark image</em> under <em>Image</em> in the <em>Geo map properties</em> dialog,
+ so that the titles are drawn in a light color. This sets the <code>#map:darkStyle</code> label.</p>
+<p>The <em>Map style</em> setting doesn't apply to an image map, so it's hidden
+ while the map has an image.</p>
<h2>Choosing the coordinate system</h2>
<p>By default, positions are measured in pixels of the image at its original
size, from its top-left corner, with <code>x</code> growing to the right
and <code>y</code> growing downwards.</p>
-<p>To use coordinates of your own instead, add a <code>#map:imageBounds</code> label
- to the geo map, naming the coordinates of the image's top-left corner and
- of its bottom-right corner as <code>x,y x,y</code>, with a space between
- the two corners. All positions are then read and written in those coordinates,
- including the ones shown in the contextual menu and in the popup view.
- For example:</p>
+<p>To use coordinates of your own instead, open the <em>Geo map properties</em> dialog,
+ set <em>Coordinates</em> under <em>Image</em> to <em>Custom</em>, and enter
+ the coordinates of the image's <em>Top-left corner</em> and <em>Bottom-right corner</em>.
+ Switching to <em>Custom</em> starts from the image's size in pixels, so the
+ markers stay where they are until the corners are changed. All positions
+ are then read and written in those coordinates, including the ones shown
+ in the contextual menu and in the popup view. To go back to pixels, set <em>Coordinates</em> to <em>Image pixels</em>.</p>
+<p>The corners are stored in the <code>#map:imageBounds</code> label of the
+ geo map as <code>x,y x,y</code>, with a space between the two corners, which
+ can also be set by hand. For example:</p>
<ul>
<li>A screenshot of a game map that covers <code>x</code> from -512 to 512 and <code>y</code> from
-512 to 512, with <code>y</code> growing downwards: <code>#map:imageBounds=-512,-512 512,512</code>.
@@ -72,8 +84,9 @@
<p>The two axes don't have to use the same scale. A circle is always measured
in the map's own units, so it appears as an ellipse when the units are
stretched differently along the two axes.</p>
-<p>A value that cannot be read, or whose corners share an <code>x</code> or
- a <code>y</code>, is ignored and the pixels of the image are used instead.</p>
+<p>Corners that share an <code>x</code> or a <code>y</code> don't span an area:
+ the dialog doesn't save them, and a label holding them, or a value that
+ cannot be read, is ignored and the pixels of the image are used instead.</p>
<h2>Coordinate rulers</h2>
<p>Enabling <em>Show scale</em> in the collection properties draws rulers along
the edges of the image instead of a distance scale. Round values of the
@@ -115,11 +128,11 @@ class="table">
<p>The positions belong to the coordinate system, not to the image. When
replacing the image with a different one, for example a higher-resolution
copy, keep <code>#map:imageBounds</code> describing the area the new image
- covers and every marker stays in place. Without <code>#map:imageBounds</code>,
- the positions are pixels, so an image of a different size moves the markers
- relative to what the image shows; to avoid that, set <code>#map:imageBounds</code> to
- the size of the old image (<code>0,0 &lt;width&gt;,&lt;height&gt;</code>)
- before replacing it.</p>
+ covers and every marker stays in place. With <em>Image pixels</em>, the
+ positions are pixels, so an image of a different size moves the markers
+ relative to what the image shows; to avoid that, switch <em>Coordinates</em> to <em>Custom</em> before
+ replacing the image, which keeps the size of the old one (<code>0,0 &lt;width&gt;,&lt;height&gt;</code>)
+ as the corners.</p>
<aside class="admonition tip">
<p>To draw freely over an image instead of placing notes on it, consider
a&nbsp;<a class="reference-link" href="#root/_help_grjYqerjn243">Canvas</a>.</p>
diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md
index a0b1fd210b..42ad1ef9bd 100644
--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md
+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md
@@ -64,6 +64,7 @@ The following entries only appear on some notes:
* <span class="tn-icon bx bx-extension"></span>_Re-render note_ appears on a <a class="reference-link" href="../../Note%20Types/Render%20Note.md">Render Note</a>, and runs its script again to refresh the output.
* <span class="tn-icon bx bx-cog"></span>_Board properties_ appears on a <a class="reference-link" href="../../Collections/Kanban%20Board.md">Kanban Board</a>, and configures its columns, card attributes and card templates.
* <span class="tn-icon bx bx-cog"></span>_Calendar properties_ appears on a <a class="reference-link" href="../../Collections/Calendar.md">Calendar</a> that creates events, and configures its event templates.
+* <span class="tn-icon bx bx-cog"></span>_Geo map properties_ appears on a <a class="reference-link" href="../../Collections/Geo%20Map.md">Geo Map</a>, and configures its map settings and the image of an [image map](../../Collections/Geo%20Map/Image%20maps.md).
## Advanced
diff --git a/docs/User Guide/User Guide/Collections/Calendar.md b/docs/User Guide/User Guide/Collections/Calendar.md
index d6412683ab..612d4a9135 100644
--- a/docs/User Guide/User Guide/Collections/Calendar.md
+++ b/docs/User Guide/User Guide/Collections/Calendar.md
@@ -96,6 +96,7 @@ In the <a class="reference-link" href="Collection%20Properties.md">Collection P
* Display week numbers on the calendar.
* Set the slot duration (the length of each time row in day/week view).
* Set the slot label interval (how often time labels appear on the axis in day/week view).
+* Limit how deep below the calendar events are looked for, with _Max nesting depth_ (see [below](#limiting-the-depth)).
The same settings, together with whether archived notes are shown, are also listed under _General_ in the <span class="tn-icon bx bx-cog"></span> _Calendar properties_ dialog (see [Event templates](#event-templates) for how to open it). The time slots are listed there whichever view the calendar is in.
@@ -212,6 +213,10 @@ This will result in:
When not used in a Journal, the calendar is recursive. That is, it will look for events not just in its child notes but also in the children of these child notes.
+### Limiting the depth
+
+To limit how deep the calendar looks for events, set _Max nesting depth_ in the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>, or the `#maxNestingDepth` label: `0` shows only the child notes, `1` adds their children, and so on. Without a value, events are looked for at every level. The setting doesn't apply in a Journal.
+
## Recurrence
The built in calendar view also supports repeating tasks (e.g. every week, every month as well as more complex recurrency rules).
diff --git a/docs/User Guide/User Guide/Collections/Geo Map.md b/docs/User Guide/User Guide/Collections/Geo Map.md
index bbf1060c76..37e9c58b22 100644
--- a/docs/User Guide/User Guide/Collections/Geo Map.md
+++ b/docs/User Guide/User Guide/Collections/Geo Map.md
@@ -393,4 +393,7 @@ The following options can be configured either via the <a class="reference-link
* The name of the markers is displayed by default underneath the pin on the map. Since v0.102.0, it is possible to hide these labels which increases the performance and decreases clutter when there are many markers on the map.
* v0.105.0 also introduces a feature called _Group nearby markers_ which will cluster multiple markers together at low zoom.
* The clusters display the number of items they contain. The color also changes based on the count.
- * Clicking on a cluster will automatically zoom in so that the individual markers that make up the cluster are now visible.
\ No newline at end of file
+ * Clicking on a cluster will automatically zoom in so that the individual markers that make up the cluster are now visible.
+* The map shows the notes of its whole subtree, not only its children. _Max nesting depth_ (`#maxNestingDepth`) limits how deep below the map it looks: `0` shows only the children, `1` adds their children, and so on. Without a value, every level is shown.
+
+The same options, together with whether archived notes are shown, are also listed under _General_ in the <span class="tn-icon bx bx-cog"></span>_Geo map properties_ dialog, opened from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> or from the settings menu of the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>. Its _Image_ section draws the map over an image of your own instead, as described in <a class="reference-link" href="Geo%20Map/Image%20maps.md">Image maps</a>.
\ No newline at end of file
diff --git a/docs/User Guide/User Guide/Collections/Geo Map/Image maps.md b/docs/User Guide/User Guide/Collections/Geo Map/Image maps.md
index d72944b9bf..7a2ad31306 100644
--- a/docs/User Guide/User Guide/Collections/Geo Map/Image maps.md
+++ b/docs/User Guide/User Guide/Collections/Geo Map/Image maps.md
@@ -5,9 +5,12 @@ An image map is a geo map drawn over an image of your own instead of a world map
1. Upload the image as a note of its own, for example by dragging the file into the note tree. PNG, JPEG, WebP and GIF images are supported; SVG images are not.
2. Create a geo map, or open an existing one.
-3. In the attributes of the geo map, add a `~map:image` [relation](../../Advanced%20Usage/Attributes/Relations.md) pointing to the image note.
+3. Open the <span class="tn-icon bx bx-cog"></span>_Geo map properties_ dialog from the <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> or from the settings menu of the <a class="reference-link" href="../Collection%20Properties.md">Collection Properties</a>.
+4. Under _Image_, choose the image note in _Image note_.
-The map then shows the image instead of the world map and opens with the whole image in view. To go back to a world map, remove the relation.
+The map then shows the image instead of the world map and opens with the whole image in view. To go back to a world map, clear _Image note_.
+
+The image note is stored in a `~map:image` [relation](../../Advanced%20Usage/Attributes/Relations.md) of the geo map, which can also be added by hand.
## Image size
@@ -18,7 +21,7 @@ Images are resized when they are uploaded, so by default the image of a map is a
An image that was already uploaded keeps its size; upload it again after changing the settings.
-The image is drawn as a single picture by the graphics card, which limits how large it can be. Images up to 4096 pixels on their longer side are safe on practically every device, and most computers handle up to 16384 pixels. On a device whose graphics card cannot hold the image, the markers and shapes still appear but the image itself does not.
+The image is drawn as a single picture by the graphics card, which limits how large it can be. Images up to 4096 pixels on their longer side are safe on practically every device, and most computers handle up to 16384 pixels. On a device whose graphics card cannot hold the image, the markers and shapes still appear but the image itself does not. The _Geo map properties_ dialog warns about an image larger than 4096 pixels, and about one that can't be used at all, such as an SVG image.
## Interaction
@@ -33,13 +36,17 @@ The features that only make sense on a real map are not available on an image ma
* The 3D buildings.
* Opening a location in an external map application.
-The look of the marker titles follows the image: if the image is dark, add the `#map:darkStyle` label to the geo map so that the titles are drawn in a light color.
+The look of the marker titles follows the image: if the image is dark, turn on _Dark image_ under _Image_ in the _Geo map properties_ dialog, so that the titles are drawn in a light color. This sets the `#map:darkStyle` label.
+
+The _Map style_ setting doesn't apply to an image map, so it's hidden while the map has an image.
## Choosing the coordinate system
By default, positions are measured in pixels of the image at its original size, from its top-left corner, with `x` growing to the right and `y` growing downwards.
-To use coordinates of your own instead, add a `#map:imageBounds` label to the geo map, naming the coordinates of the image's top-left corner and of its bottom-right corner as `x,y x,y`, with a space between the two corners. All positions are then read and written in those coordinates, including the ones shown in the contextual menu and in the popup view. For example:
+To use coordinates of your own instead, open the _Geo map properties_ dialog, set _Coordinates_ under _Image_ to _Custom_, and enter the coordinates of the image's _Top-left corner_ and _Bottom-right corner_. Switching to _Custom_ starts from the image's size in pixels, so the markers stay where they are until the corners are changed. All positions are then read and written in those coordinates, including the ones shown in the contextual menu and in the popup view. To go back to pixels, set _Coordinates_ to _Image pixels_.
+
+The corners are stored in the `#map:imageBounds` label of the geo map as `x,y x,y`, with a space between the two corners, which can also be set by hand. For example:
* A screenshot of a game map that covers `x` from -512 to 512 and `y` from -512 to 512, with `y` growing downwards: `#map:imageBounds=-512,-512 512,512`. Coordinates copied from the game can then be pasted directly into `#mapPosition`.
* A world whose `y` grows upwards, with the origin in the middle of the image: `#map:imageBounds=-2000,1000 2000,-1000`. A top-left `y` larger than the bottom-right one is what flips the axis.
@@ -47,7 +54,7 @@ To use coordinates of your own instead, add a `#map:imageBounds` label to the ge
The two axes don't have to use the same scale. A circle is always measured in the map's own units, so it appears as an ellipse when the units are stretched differently along the two axes.
-A value that cannot be read, or whose corners share an `x` or a `y`, is ignored and the pixels of the image are used instead.
+Corners that share an `x` or a `y` don't span an area: the dialog doesn't save them, and a label holding them, or a value that cannot be read, is ignored and the pixels of the image are used instead.
## Coordinate rulers
@@ -64,7 +71,7 @@ Because positions are stored in different labels from the ones of a geo map, the
| `#mapPosition` | The position of a marker, as `x,y`, for example `#mapPosition=320,145`. |
| `#mapShape` | A shape, in the same format as `#geoShape` (see <a class="reference-link" href="Drawing%20shapes.md">Drawing shapes</a>) but with `x,y` pairs, and a circle's radius in the map's units, for example `#mapShape=circle:400,300 50`. |
-The positions belong to the coordinate system, not to the image. When replacing the image with a different one, for example a higher-resolution copy, keep `#map:imageBounds` describing the area the new image covers and every marker stays in place. Without `#map:imageBounds`, the positions are pixels, so an image of a different size moves the markers relative to what the image shows; to avoid that, set `#map:imageBounds` to the size of the old image (`0,0 <width>,<height>`) before replacing it.
+The positions belong to the coordinate system, not to the image. When replacing the image with a different one, for example a higher-resolution copy, keep `#map:imageBounds` describing the area the new image covers and every marker stays in place. With _Image pixels_, the positions are pixels, so an image of a different size moves the markers relative to what the image shows; to avoid that, switch _Coordinates_ to _Custom_ before replacing the image, which keeps the size of the old one (`0,0 <width>,<height>`) as the corners.
> [!TIP]
> To draw freely over an image instead of placing notes on it, consider a <a class="reference-link" href="../../Note%20Types/Canvas.md">Canvas</a>.
\ No newline at end of file