Skip to content

Commit

Permalink
tested if registering the click event handler post load does fix …
Browse files Browse the repository at this point in the history
…the `click` handler not getting triggered
  • Loading branch information
CommanderStorm committed Aug 7, 2024
1 parent cc9ee83 commit 1645e02
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions webclient/app/components/DetailsInteractiveMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,21 @@ function initMap(containerId: string) {
attributionControl: false,
});
map.on("click", "overlay-layer", (e) => {
if (e.type === "contextmenu" || e.type === "dblclick") {
console.log(`got click ${+e} for ${props.data.id}: ${e.lngLat}`);
navigator.clipboard.writeText(`${props.data.id}: ${e.lngLat}`);
}
});
// Each source / style change causes the map to get
// into "loading" state, so map.loaded() is not reliable
// enough to know whether just the initial loading has
// succeeded.
map.on("load", () => {
initialLoaded.value = true;
// event handler needs to be registered post-load otherwise it is silently ignored
map.on("click", "overlay-layer", (e) => {
if (e.type === "contextmenu" || e.type === "dblclick") {
console.log(`got click ${+e} for ${props.data.id}: ${e.lngLat}`);
navigator.clipboard.writeText(`${props.data.id}: ${e.lngLat}`);
}
});
// controls
map.addControl(new NavigationControl({}), "top-left");
Expand Down

0 comments on commit 1645e02

Please sign in to comment.