diff options
Diffstat (limited to 'templates/index.js')
| -rw-r--r-- | templates/index.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/templates/index.js b/templates/index.js index b7b3b58..d4cc5a5 100644 --- a/templates/index.js +++ b/templates/index.js @@ -3,6 +3,7 @@ const form = document.querySelector('#path-form') const markerIsStart = document.querySelector("#marker-point-start") const markerIsEnd = document.querySelector("#marker-point-end") form.addEventListener('submit', postShortestPath, false) +document.querySelector("#osm-file-form").addEventListener('submit', loadFile, false) L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' @@ -33,6 +34,15 @@ async function postShortestPath(event){ } +async function loadFile(event) { + event.preventDefault() + await fetch("/load-file", { + method: "POST", + credentials: "same-origin", + body: JSON.stringify({"filename": document.querySelector("#filename").value}) + }) +} + function handleMapClick ({latlng}){ var {lat, lng} = latlng var marker = L.marker([lat, lng]).addTo(map) |
