Skip to content

Build your personal knowledge base with Trilium Notes

chore(collections/map): fix type issue

Elian Dorana53dc1193bf1
diff --git a/apps/client/src/widgets/collections/geomap/Markers.tsx b/apps/client/src/widgets/collections/geomap/Markers.tsx
index 33192d0e7c..6d6e1fd1e1 100644
--- a/apps/client/src/widgets/collections/geomap/Markers.tsx
+++ b/apps/client/src/widgets/collections/geomap/Markers.tsx
@@ -1,4 +1,4 @@
-import { GeoJSONSource } from "maplibre-gl";
+import { type GeoJSONSource } from "maplibre-gl";
import { useCallback, useContext, useEffect } from "preact/hooks";
import FNote from "../../../entities/fnote";
@@ -63,7 +63,7 @@ export default function Markers({ note }: { note: FNote }) {
return key;
}
- const features: maplibregl.GeoJSONFeature[] = [];
+ const features: GeoJSON.Feature[] = [];
for (const childNote of childNotes) {
const location = childNote.getLabelValue(LOCATION_ATTRIBUTE);
const latLng = location?.split(",", 2).map((el) => parseFloat(el)) as [ number, number ] | undefined;
diff --git a/apps/client/src/widgets/collections/geomap/Tooltips.tsx b/apps/client/src/widgets/collections/geomap/Tooltips.tsx
index 807e5c8946..387056a4f6 100644
--- a/apps/client/src/widgets/collections/geomap/Tooltips.tsx
+++ b/apps/client/src/widgets/collections/geomap/Tooltips.tsx
@@ -1,4 +1,4 @@
-import { MapMouseEvent, Popup } from "maplibre-gl";
+import { type MapGeoJSONFeature, MapMouseEvent, Popup } from "maplibre-gl";
import { useContext, useEffect } from "preact/hooks";
import { ParentMap } from "./map";
@@ -17,10 +17,12 @@ export default function Tooltips() {
className: "marker-tooltip"
});
- function onMouseEnter(e: MapMouseEvent) {
- const feature = e.features[0];
+ function onMouseEnter(e: MapMouseEvent & { features?: MapGeoJSONFeature[]; }) {
+ const feature = e.features?.[0];
+ if (!feature || !map || feature.geometry.type !== "Point") return;
+
tooltip
- .setLngLat(feature.geometry.coordinates)
+ .setLngLat(feature.geometry.coordinates as [ number, number ])
.setHTML(`<strong>${feature.properties.name}</strong>`)
.addTo(map);
}