From 259bee0b259a64db5520f6d3e93d9457a45bfb33 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Thu, 8 Jul 2021 10:39:04 -0400 Subject: [PATCH] Include query params in geojson URL --- datasette_geojson_map/static/map.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/datasette_geojson_map/static/map.js b/datasette_geojson_map/static/map.js index b9ea424..1cf7f0c 100644 --- a/datasette_geojson_map/static/map.js +++ b/datasette_geojson_map/static/map.js @@ -6,7 +6,7 @@ async function render() { console.debug("Rendering GeoJSON map"); // window.datasette.leaflet.JAVASCRIPT_URL const L = await import(window.datasette.leaflet.JAVASCRIPT_URL); - const geojson = await fetch(location.pathname + ".geojson").then(r => r.json()); + const geojson = await fetch(geojsonURL(window.location)).then(r => r.json()); const parent = document.querySelector(".table-wrapper"); const container = document.createElement("DIV"); @@ -35,6 +35,12 @@ function createMap(L, container) { return map; } +function geojsonURL(location) { + const url = new URL(location); + url.pathname = url.pathname + ".geojson"; + return url; +} + function popup(layer) { const { properties } = layer.feature; const items = Object.entries(properties).map(