-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbd_map_v1.html
71 lines (67 loc) · 1.78 KB
/
bd_map_v1.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
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bangladesh Map</title>
<style>
/* Set the height and width of the map container */
#map {
height: 500px;
width: 100%;
}
/* Style for the districts */
.district {
fill: #ff0000;
stroke: #ffffff;
stroke-width: 1;
}
</style>
</head>
<body>
<!-- Container for the map -->
<div id="map"></div>
<!-- SVG with the district paths -->
<svg width="100%" height="500">
<path class="district" id="Dhaka" d="M ...." />
<!-- Add more paths for other districts -->
</svg>
<script>
// Get all the districts
const districts = document.querySelectorAll('.district');
// Set the fill color for each district
districts.forEach(district => {
district.style.fill = getDistrictColor(district.id);
});
// Show information for the district when clicked
districts.forEach(district => {
district.addEventListener('click', function () {
alert(`District: ${this.id}\nPopulation: ${getDistrictPopulation(this.id)}`);
});
});
// Function to return the fill color for each district
function getDistrictColor(districtName) {
switch (districtName) {
case 'Dhaka':
return '#ff0000';
case 'Rangpur':
return '#00ff00';
// Add more cases for other districts
default:
return '#ffffff';
}
}
// Function to return the population for each district
function getDistrictPopulation(districtName) {
switch (districtName) {
case 'Dhaka':
return '10,000,000';
case 'Rangpur':
return '5,000,000';
// Add more cases for other districts
default:
return 'Unknown';
}
}
</script>
</body>
</html>