chore(collections/map): fix type issue

This commit is contained in:
Elian Doran
2026-02-16 20:33:48 +02:00
parent 0d169b0641
commit a53dc1193b
2 changed files with 8 additions and 6 deletions

View File

@@ -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;

View File

@@ -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);
}