Support pasting lat,lon coordinates into either lat or lon map field (#1687)

This commit is contained in:
Tim Wilkinson 2024-11-13 08:41:40 -08:00 committed by GitHub
parent 56e53a5324
commit 9630ec6656
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 0 deletions

View File

@ -201,8 +201,26 @@ const mapurl = map ? replace(replace(map, "(lat)", lat), "(lon)", lon) : null;
});
}
}
function llpaste() {
const txt = event.clipboardData.getData("text/plain");
if (!txt) {
return;
}
event.stopPropagation();
event.preventDefault();
const ll = txt.split(",");
const latv = parseFloat(ll[0]);
const lonv = parseFloat(ll[1]);
if (!isNaN(latv) && !isNaN(lonv)) {
lat.value = latv;
lon.value = lonv;
llchange();
}
}
lat.addEventListener("change", llchange);
lon.addEventListener("change", llchange);
lat.addEventListener("paste", llpaste);
lon.addEventListener("paste", llpaste);
gridsquare.addEventListener("change", function() {
if (gridsquare.value !== "") {
gridsquare2latlon();