From 289fac1e7e61b27267091f84054fba6a2df01839 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 11 Mar 2026 15:12:59 +0000 Subject: [PATCH] Set marker on click on aerial imagery --- html/static/js/map-proxied-arcgis-tile.js | 14 ++++++++++++++ html/template/sync/review/pool.html | 20 +++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/html/static/js/map-proxied-arcgis-tile.js b/html/static/js/map-proxied-arcgis-tile.js index ad965c46..f41cc785 100644 --- a/html/static/js/map-proxied-arcgis-tile.js +++ b/html/static/js/map-proxied-arcgis-tile.js @@ -90,6 +90,20 @@ class MapProxiedArcgisTile extends HTMLElement { map: this, }, }); + this._map.on("click", (e) => { + this.dispatchEvent( + new CustomEvent("map-click", { + bubbles: true, + composed: true, + detail: { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + map: this, + point: e.point, + }, + }), + ); + }); }); for (const on of this._preOns) { this._map.on(on.a, on.b); diff --git a/html/template/sync/review/pool.html b/html/template/sync/review/pool.html index f91243cf..de6125ed 100644 --- a/html/template/sync/review/pool.html +++ b/html/template/sync/review/pool.html @@ -271,15 +271,21 @@ this.submitReview("discarded"); } }, - updatePoolLocation(event, signal_id) { - console.log("map click", signal_id, event.detail); - const map = event.detail.map; + updatePoolLocation(e, pool_id) { + console.log("map click", pool_id, e.detail); + const map = e.detail.map; const loc = { - latitude: event.detail.lat, - longitude: event.detail.lng, + latitude: e.detail.lat, + longitude: e.detail.lng, }; - map.SetMarkers([loc]); - this.form.poolLocation[signal_id] = loc; + map.SetMarkers([ + new maplibregl.Marker({ + color: "#FF0000", + draggable: false, + }).setLngLat([e.detail.lng, e.detail.lat]), + ]); + this.form.latitude = e.detail.lat; + this.form.longitude = e.detail.lng; }, }; }