82 lines
1.5 KiB
Plaintext
82 lines
1.5 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
|
|
<title>Map Developer</title>
|
|
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
background: #000;
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
|
|
.wrapper {
|
|
position: relative;
|
|
}
|
|
|
|
img {
|
|
display: block;
|
|
}
|
|
|
|
svg {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
|
|
polygon {
|
|
fill: rgba(255, 0, 0, 0.35);
|
|
stroke: red;
|
|
stroke-width: 2;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="wrapper">
|
|
<img src="/images/dok_bg.png" id="map" />
|
|
|
|
<svg
|
|
id="overlay"
|
|
viewBox="0 0 2037 1018"
|
|
width="2037"
|
|
height="1018"
|
|
></svg>
|
|
</div>
|
|
|
|
<script>
|
|
let points = [];
|
|
const svg = document.getElementById("overlay");
|
|
|
|
svg.addEventListener("click", (e) => {
|
|
const rect = svg.getBoundingClientRect();
|
|
|
|
const x = Math.round(e.clientX - rect.left);
|
|
const y = Math.round(e.clientY - rect.top);
|
|
|
|
points.push(`${x},${y}`);
|
|
|
|
drawPolygon();
|
|
|
|
console.log('points="' + points.join(" ") + '"');
|
|
});
|
|
|
|
function drawPolygon() {
|
|
svg.innerHTML = `
|
|
<polygon points="${points.join(" ")}"></polygon>
|
|
`;
|
|
}
|
|
|
|
document.addEventListener("keydown", (e) => {
|
|
if (e.key === "Escape") {
|
|
points = [];
|
|
svg.innerHTML = "";
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|