From b5ea2054c1708e6d574e0fc9ed0c0937a28357f2 Mon Sep 17 00:00:00 2001 From: Roland Date: Sun, 4 Oct 2026 17:09:33 -0600 Subject: [PATCH] Open the Solar calculator from the map, pins and current location The map's right-click (or long-press) menu gains "Calculate Solar Performance", and each saved pin a sun button; both open the calculator at that location. A button beside Latitude fills in the browser's current location. Locations are rounded to 4 decimals, and longitudes from a map panned around the world are wrapped back to -180..180. The map removed lat/lon/z from the URL when it closed, even after navigating to another page, which stripped the calculator's location from its URL (and from links shared with the Share button). It now only cleans up while the URL is still a map page. Co-Authored-By: Claude Opus 5.5 --- app/src/components/Map.js | 28 +++++++---- app/src/components/MapTables.test.js | 12 ++++- app/src/components/MapViewer.js | 32 ++++++++++--- app/src/components/MapViewer.test.js | 45 ++++++++++++++++++ .../components/calculators/SolarCalculator.js | 47 +++++++++++++++++-- .../calculators/SolarCalculator.test.js | 37 +++++++++++++++ app/src/components/calculators/solar.js | 9 ++++ app/src/components/calculators/solar.test.js | 14 ++++++ app/src/components/ui/Icon.tsx | 1 + 9 files changed, 203 insertions(+), 22 deletions(-) create mode 100644 app/src/components/MapViewer.test.js diff --git a/app/src/components/Map.js b/app/src/components/Map.js index 3c5ed0d5..46b2554d 100644 --- a/app/src/components/Map.js +++ b/app/src/components/Map.js @@ -20,6 +20,7 @@ import {Media, StatusContext} from "../contexts/contexts"; import {MAP_VIEWER_URI} from "./Vars"; import MapViewer from "./MapViewer"; import {AddToPlaylistButton} from "./AddToPlaylist"; +import {solarCalculatorPath} from "./calculators/solar"; import maplibregl from "maplibre-gl"; import {Protocol} from "pmtiles"; import layers from "protomaps-themes-base"; @@ -567,6 +568,9 @@ function MapPins() { navigate(`/map?lat=${pin.lat}&lon=${pin.lon}&z=14`); }; + const solarButton = (pin) =>