Skip to content

Build your personal knowledge base with Trilium Notes

feat(geomap): add floating button section

Elian Doranf803b9f8225c
diff --git a/src/public/app/entities/fnote.ts b/src/public/app/entities/fnote.ts
index 1071ce1a48..053ac6be5f 100644
--- a/src/public/app/entities/fnote.ts
+++ b/src/public/app/entities/fnote.ts
@@ -36,7 +36,7 @@ const NOTE_TYPE_ICONS = {
* end user. Those types should be used only for checking against, they are
* not for direct use.
*/
-type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap";
+type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap" | "geoMap";
interface NotePathRecord {
isArchived: boolean;
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js
index a50dace76d..c5d14ffe96 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.js
@@ -85,6 +85,7 @@ import ScrollPaddingWidget from "../widgets/scroll_padding.js";
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
import options from "../services/options.js";
import utils from "../services/utils.js";
+import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
export default class DesktopLayout {
constructor(customWidgets) {
@@ -200,6 +201,7 @@ export default class DesktopLayout {
.child(new ShowHighlightsListWidgetButton())
.child(new CodeButtonsWidget())
.child(new RelationMapButtons())
+ .child(new GeoMapButtons())
.child(new CopyImageReferenceButton())
.child(new SvgExportButton())
.child(new BacklinksWidget())
diff --git a/src/public/app/widgets/floating_buttons/geo_map_button.ts b/src/public/app/widgets/floating_buttons/geo_map_button.ts
new file mode 100644
index 0000000000..f1fcc9dd90
--- /dev/null
+++ b/src/public/app/widgets/floating_buttons/geo_map_button.ts
@@ -0,0 +1,40 @@
+import NoteContextAwareWidget from "../note_context_aware_widget.js"
+
+const TPL = `\
+<div class="geo-map-buttons">
+ <style>
+ .geo-map-buttons {
+ display: flex;
+ gap: 10px;
+ }
+
+ .leaflet-pane {
+ z-index: 50;
+ }
+
+ .geo-map-buttons {
+ contain: none;
+ background: var(--main-background-color);
+ box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
+ border-radius: 4px;
+ }
+ </style>
+
+ <button type="button"
+ class="geo-map-create-child-note floating-button btn bx bx-folder-plus"
+ title="Create new child note and add it to the map" />
+</div>`;
+
+export default class GeoMapButtons extends NoteContextAwareWidget {
+
+ isEnabled() {
+ return super.isEnabled() && this.note?.type === "geoMap";
+ }
+
+ doRender() {
+ super.doRender();
+
+ this.$widget = $(TPL);
+ }
+
+}
diff --git a/src/public/app/widgets/type_widgets/geo_map.ts b/src/public/app/widgets/type_widgets/geo_map.ts
index 38a81ab10e..35a3da7902 100644
--- a/src/public/app/widgets/type_widgets/geo_map.ts
+++ b/src/public/app/widgets/type_widgets/geo_map.ts
@@ -3,7 +3,14 @@ import type FNote from "../../entities/fnote.js";
import GeoMapWidget from "../geo_map.js";
import TypeWidget from "./type_widget.js"
-const TPL = `<div class="note-detail-geo-map note-detail-printable"></div>`;
+const TPL = `\
+<div class="note-detail-geo-map note-detail-printable">
+ <style>
+ .leaflet-pane {
+ z-index: 1;
+ }
+ </style>
+</div>`;
interface MapData {
view?: {