Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions coordo-ts/src/layers/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ export function makeSetLayerPopup({ map }: { map: MapLibreMap }) {
}

const onTrigger = async (ev: MapLayerMouseEvent | MapLayerTouchEvent) => {
const geometry = ev.features?.[0]?.geometry;
const lngLat = ev.lngLat;
const eventProps = ev.features?.[0]?.properties;
const id = ev.features?.[0]?.id;
if (geometry && id && eventProps) {
if (lngLat && Number(id) >= 0 && eventProps) {
/** @todo Remove "any" casting */
const popup = new Popup(popupConfig).setLngLat(ev.lngLat);

Expand All @@ -124,6 +124,14 @@ export function makeSetLayerPopup({ map }: { map: MapLibreMap }) {
}

popup.addTo(map);
} else if (!lngLat) {
console.warn("Missing property lngLat on event : ", ev);
} else if (!ev.features) {
console.warn("Event features not found");
} else if (!(Number(id) >= 0)) {
console.warn("event feature id is invalid: ", id);
} else if (!eventProps) {
console.warn("Event feature properties not found", eventProps);
}
};

Expand Down
Loading