From 38906db8163bdecbe74fed85bb3edcbadc5b96ec Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 3 Mar 2026 20:27:33 +0000 Subject: [PATCH] Move standing woter to use libremap instead of mapbox --- html/static/js/map-cell.js | 1 - html/static/js/map-locator.js | 79 ++++++++++++++++-------------- html/template/rmo/mailer/root.html | 11 ++++- html/template/rmo/water.html | 5 +- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/html/static/js/map-cell.js b/html/static/js/map-cell.js index 8e4dcea2..3a2b27d6 100644 --- a/html/static/js/map-cell.js +++ b/html/static/js/map-cell.js @@ -1,4 +1,3 @@ -var map = null; // A map for showing a single h3 cell class MapCell extends HTMLElement { constructor() { diff --git a/html/static/js/map-locator.js b/html/static/js/map-locator.js index 251bc9dd..237015b7 100644 --- a/html/static/js/map-locator.js +++ b/html/static/js/map-locator.js @@ -5,7 +5,7 @@ class MapLocator extends HTMLElement { super(); // Create a shadow DOM - this.attachShadow({mode: "open" }); + this.attachShadow({ mode: "open" }); // Initial render this.render(); @@ -29,66 +29,71 @@ class MapLocator extends HTMLElement { _initializeMap() { console.log("Setting up the map..."); const apiKey = this.getAttribute("api-key"); - const lat = Number(this.getAttribute('latitude') || 36.2); - const lng = Number(this.getAttribute('longitude') || -119.2); - const zoom = Number(this.getAttribute('zoom') || 15); + const lat = Number(this.getAttribute("latitude") || 36.2); + const lng = Number(this.getAttribute("longitude") || -119.2); + const zoom = Number(this.getAttribute("zoom") || 15); - mapboxgl.accessToken = apiKey; const mapElement = this.shadowRoot.querySelector("#map"); - this._map = new mapboxgl.Map({ + this._map = new maplibregl.Map({ container: mapElement, center: { lat: lat, lng: lng, }, - style: 'mapbox://styles/mapbox/streets-v12', // style URL + style: "https://tiles.stadiamaps.com/styles/alidade_smooth.json", zoom: zoom, }); /* - map.addControl(new mapboxgl.GeolocateControl({ + map.addControl(new maplibregl.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true, showUserHeading: true })); - map.addControl(new mapboxgl.NavigationControl()); + map.addControl(new maplibregl.NavigationControl()); */ this._map.on("click", (e) => { e.preventDefault(); console.log("internal click", e); - this.dispatchEvent(new CustomEvent("click", { - bubbles: true, - composed: true, // Allows event to cross shadow DOM boundary - detail: { - lngLat: e.lngLat, - }, - })); + this.dispatchEvent( + new CustomEvent("click", { + bubbles: true, + composed: true, // Allows event to cross shadow DOM boundary + detail: { + lngLat: e.lngLat, + }, + }), + ); }); this._map.on("load", () => { console.log("map loaded"); - this.dispatchEvent(new CustomEvent("load", { - bubbles: true, - composed: true, // Allows event to cross shadow DOM boundary - detail: { - map: this - } - })); + this.dispatchEvent( + new CustomEvent("load", { + bubbles: true, + composed: true, // Allows event to cross shadow DOM boundary + detail: { + map: this, + }, + }), + ); }); this._map.on("zoomend", (e) => { - this.dispatchEvent(new CustomEvent("zoomend", { - bubbles: true, - composed: true, - detail: e, - })); + this.dispatchEvent( + new CustomEvent("zoomend", { + bubbles: true, + composed: true, + detail: e, + }), + ); }); } // Initial render of component render() { this.shadowRoot.innerHTML = ` -