-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.html
67 lines (59 loc) · 1.73 KB
/
temp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temp Map</title>
<style>
#map-container {
width: 800px;
height: 600px;
overflow: hidden;
border: 2px solid black;
position: relative;
}
#map {
position: absolute;
width: 1600px; /* Double the container size for zooming */
height: 1200px;
cursor: grab;
}
</style>
</head>
<body>
<div id="map-container">
<img id="map" src="/Screenshot (123).png" alt="Custom Map">
</div>
<script>
let map = document.getElementById("map");
let mapContainer = document.getElementById("map-container");
let isDragging = false;
let startX, startY, startLeft, startTop;
map.addEventListener("mousedown", function (e) {
isDragging = true;
startX = e.clientX;
startY = e.clientY;
startLeft = map.offsetLeft;
startTop = map.offsetTop;
});
document.addEventListener("mousemove", function (e) {
if (isDragging) {
let dx = e.clientX - startX;
let dy = e.clientY - startY;
map.style.left = startLeft + dx + "px";
map.style.top = startTop + dy + "px";
}
});
document.addEventListener("mouseup", function () {
isDragging = false;
});
// Zoom Feature
mapContainer.addEventListener("wheel", function (e) {
e.preventDefault();
let scale = e.deltaY > 0 ? 0.9 : 1.1;
map.style.width = map.offsetWidth * scale + "px";
map.style.height = map.offsetHeight * scale + "px";
});
</script>
</body>
</html>