-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjourney-map.js
46 lines (35 loc) · 1.69 KB
/
journey-map.js
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
document.addEventListener("DOMContentLoaded", function () {
console.log("Document is loaded and parsed");
const map = document.getElementById("map");
const tooltip = document.getElementById("tooltip");
const regions = document.querySelectorAll(".regions .region");
console.log(`Found ${regions.length} region elements`);
regions.forEach((region, index) => {
console.log(`Region ${index + 1}: `, region);
region.addEventListener("mouseover", function (event) {
const { x, y, width, height, text, url } = region.dataset;
console.log(`Mouseover event for Region ${index + 1} at coordinates (x: ${x}, y: ${y}). Width: ${width}, Height: ${height}. Text: ${text}, URL: ${url}`);
tooltip.innerText = text;
tooltip.style.top = `${parseInt(y) + map.offsetTop}px`;
tooltip.style.left = `${parseInt(x) + map.offsetLeft + parseInt(width)}px`;
tooltip.style.display = "block";
});
region.addEventListener("mouseout", function (event) {
console.log(`Mouseout event for Region ${index + 1}`);
tooltip.style.display = "none";
});
region.addEventListener("click", function (event) {
const { url } = region.dataset;
console.log(`Click event for Region ${index + 1}, navigating to URL: ${url}`);
window.location.href = url;
});
region.addEventListener("mouseover", function (event) {
const { x, y, width, height, text, url } = region.dataset;
console.log(`x and y values before parsing: x=${x}, y=${y}`);
const parsedX = parseInt(x);
const parsedY = parseInt(y);
console.log(`x and y values after parsing: x=${parsedX}, y=${parsedY}`);
// Rest of your code...
});
});
});