Skip to content

Commit

Permalink
generate url, allowing previewing from branches and localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
dschep committed Jul 24, 2024
1 parent 18ec4d6 commit ecdd971
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand All @@ -9,7 +9,10 @@
<style>
html,
body,
#map {
#map,
iframe {
display: flex;
border: none;
height: 100%;
width: 100%;
margin: 0;
Expand All @@ -18,7 +21,15 @@
</style>
</head>
<body>
<script defer src="https://overpass-ultra.us/embed.js" style="display:block;height:100%;width:100%;border:none;">
<iframe></iframe>
<script>
let geojson = "https://maprva.github.io/open-landmarks/landmarks.geojson";
if (window.location.host.startsWith("localhost:")) {
geojson = `${window.location.origin}/landmarks.geojson`;
} else {
geojson = `${window.location.origin}/open-landmarks/landmarks.geojson`;
}
const query = `
---
type: geojson
options:
Expand All @@ -28,7 +39,6 @@
extends: https://styles.trailsta.sh/osm-bright.json
layers:
- type: symbol
minzoom: 12
icon-image:
- concat
- /icons/
Expand Down Expand Up @@ -61,8 +71,10 @@
<br>
{%- endfor %}
---
https://maprva.github.io/open-landmarks/landmarks.geojson
${geojson}
`;
document.querySelector("iframe").src =
`https://overpass-ultra.us/#map&query=${encodeURIComponent(query.trim())}`;
</script>
</body>
</html>

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"main": "build.js",
"scripts": {
"start": "http-server -c-1",
"start": "http-server -c-1 --cors",
"build:geojson": "node build.js"
},
"author": "",
Expand Down

0 comments on commit ecdd971

Please sign in to comment.