From 60a1eba2eb11e24fb4bc2d2e61acd0131b5daf6d Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 17 Nov 2025 22:13:02 +0000 Subject: [PATCH] Detect clicks on hexes in the map display. This will allow us to focus on a single region. --- templates/dashboard.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/templates/dashboard.html b/templates/dashboard.html index b330e0b7..58778d1e 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -59,6 +59,34 @@ function onLoad() { } //slot: 'middle' // middle slot in Mapbox Standard style }); + map.addInteraction("nidus-click-interaction", { + type: 'click', + target: { layerId: 'nidus' }, + handler: (e) => { + const coordinates = e.feature.geometry.coordinates.slice(); + const properties = e.feature.properties; + //console.log("Coordinates", coordinates[0]); + //console.log("Properties", properties.cell, properties.count_); + new mapboxgl.Popup() + .setLngLat(coordinates[0][0]) + .setHTML("Cell: " + properties.cell) + .addTo(map); + } + }); + map.addInteraction('nidus-mouseenter-interaction', { + type: 'mouseenter', + target: { layerId: 'nidus' }, + handler: () => { + map.getCanvas().style.cursor = 'pointer'; + } + }); + map.addInteraction('nidus-mouseleave-interaction', { + type: 'mouseleave', + target: { layerId: 'nidus' }, + handler: () => { + map.getCanvas().style.cursor = ''; + } + }); console.log("Map post-load done."); });