Add coordinate precision function

This commit is contained in:
Marwin Hochfelsner 2025-01-30 06:21:07 +01:00
parent 09e802b86c
commit 4b6b49801c
9 changed files with 59 additions and 103 deletions

View file

@ -36,16 +36,16 @@ OSM.Export = function (map) {
}
function setBounds(bounds) {
var precision = OSM.zoomPrecision(map.getZoom());
$("#minlon").val(bounds.getWest().toFixed(precision));
$("#minlat").val(bounds.getSouth().toFixed(precision));
$("#maxlon").val(bounds.getEast().toFixed(precision));
$("#maxlat").val(bounds.getNorth().toFixed(precision));
const truncated = [bounds.getSouthWest(), bounds.getNorthEast()]
.map(c => OSM.cropLocation(c, map.getZoom()));
$("#minlon").val(truncated[0][1]);
$("#minlat").val(truncated[0][0]);
$("#maxlon").val(truncated[1][1]);
$("#maxlat").val(truncated[1][0]);
$("#export_overpass").attr("href",
"https://overpass-api.de/api/map?bbox=" +
$("#minlon").val() + "," + $("#minlat").val() + "," +
$("#maxlon").val() + "," + $("#maxlat").val());
truncated.map(p => p.reverse()).join());
}
function validateControls() {