Skip to content

Commit

Permalink
Include query params in geojson URL
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Jul 8, 2021
1 parent 7627f9e commit 259bee0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion datasette_geojson_map/static/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 259bee0

Please sign in to comment.