Add loadMapFromUrl

This commit is contained in:
hasparus 2018-10-17 11:31:11 +02:00
parent f5c507a94b
commit 13ad4f941c
No known key found for this signature in database
GPG key ID: 199946486FC7B0AC
3 changed files with 41 additions and 2 deletions

18
src/loadMapFromUrl.js Normal file
View file

@ -0,0 +1,18 @@
function makeFileFromUrl(mapLink, callback) {
fetch(mapLink, {
method: 'GET',
mode: 'cors',
})
.then(response => response.blob())
.then(blob => callback(blob));
}
function loadMapFromUrl(uploadFile) {
const url = new URL(location.href);
const mapLink = url.searchParams.get('maplink');
if (mapLink) {
makeFileFromUrl(decodeURIComponent(mapLink), uploadFile);
}
}
window.loadMapFromUrl = loadMapFromUrl;