Skip to content

Commit

Permalink
fix: centroid in url and fix zonage
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Feb 19, 2024
1 parent 84969c7 commit 2bc3f3e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function updateInfo(info, coords) {
duration: 500,
});
const [lon, lat] = coords;
history.replaceState(null, "", "?g=" + encodeURICompoenent(`${lat},${lon}`));
history.replaceState(null, "", "?g=" + encodeURIComponent(`${lat},${lon}`));
}

function infoError(txt: string) {
Expand Down Expand Up @@ -208,14 +208,16 @@ map.on("click", async (evt) => {
window.addEventListener("load", async () => {
const response = await fetch(`${ALEXI_URL}/index.json`);
if (response.ok) {
zonage = await response.json();
const metadata = await response.json();
zonage = metadata.zonage;
}
const urlParams = new URLSearchParams(window.location.search);
const centroid = urlParams.get("g");
if (centroid !== null) {
const [lat, lon] = centroid.split(",").map(parseFloat);
const coords = [lon, lat];
const projPos = fromLonLat(coords);
source.addFeature(new Feature(new Point(projPos)));
view.animate({center: projPos});
getInfo(coords);
}
Expand Down

0 comments on commit 2bc3f3e

Please sign in to comment.