feat: fit map to screen size

This commit is contained in:
Azgaar 2023-11-19 16:51:59 +04:00
parent ada39b47ad
commit 1200b9e60f
8 changed files with 64 additions and 75 deletions

View file

@ -623,10 +623,12 @@ function drawScaleBar(scaleLevel) {
// fit ScaleBar to canvas size
function fitScaleBar() {
if (!scaleBar.select("rect").size() || scaleBar.style("display") === "none") return;
const px = isNaN(+barPosX.value) ? 0.99 : barPosX.value / 100;
const py = isNaN(+barPosY.value) ? 0.99 : barPosY.value / 100;
const bbox = scaleBar.select("rect").node().getBBox();
const x = rn(svgWidth * px - bbox.width + 10),
y = rn(svgHeight * py - bbox.height + 20);
const x = rn(svgWidth * px - bbox.width + 10);
const y = rn(svgHeight * py - bbox.height + 20);
scaleBar.attr("transform", `translate(${x},${y})`);
}