-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20240314-map_v3.html
More file actions
114 lines (98 loc) · 4.08 KB
/
Copy path20240314-map_v3.html
File metadata and controls
114 lines (98 loc) · 4.08 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!-- 口罩地圖 - 全國分布圖 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>口罩地圖 - 全國分布圖 cluster</title>
<link rel="shortcut icon" href="images/icon/icon.ico" type="images/x-icon"><!-- icon更換 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/myall.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
<link rel="stylesheet" href="css/MarkerCluster.css">
<style>
.marker-cluster-small {
background-color: rgba(219, 191, 219, 0.5);
}
.marker-cluster-small div {
background-color: rgba(153, 32, 102, 0.7);
}
.marker-cluster-medium {
background-color: rgba(63, 223, 22, 0.5);
}
.marker-cluster-medium div {
background-color: rgba(23, 78, 27, 0.7);
}
.marker-cluster-large {
background-color: rgba(216, 233, 243, 0.5);
}
.marker-cluster-large div {
background-color: rgba(21, 53, 88, 0.7);
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-top: 5px;
margin-left: 5px;
text-align: center;
border-radius: 50%;
font-size: 14;
font-weight: 900;
}
.marker-cluste span {
line-height: 30px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row vh-100">
<div class="col-md-12 bg-warning">
<div id="map" class="vh-100"></div>
</div>
</div>
</div>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios@1.6.7/dist/axios.min.js"></script>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script src="js/leaflet.markercluster.js"></script>
<script>
var allMaskData = []; //健保局口罩藥局資料
var map;
var markers;
$(function () {
//draw map
// 放大倍率為8
map = L.map('map').setView([24.171477, 120.609643], 8);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
markers = new L.markerClusterGroup().addTo(map);
//載入健保局資料
axios.get('js/points.json')
.then(function (response) {
// handle success
console.log(response.data.features);
allMaskData = response.data.features;
allMaskData.forEach(function (item, key) {
//加上水滴座標
var lat = item.geometry.coordinates[1];
var lng = item.geometry.coordinates[0];
var popupHTML = '<div class="card"><div class="card-body"><h4>' + item.properties.name + '</h4><h5>地址: ' + item.properties.address + '</h5><h5>電話: ' + item.properties.phone + '</h5><h5>成人口罩: <span class="text-danger h4 fw-900">' + item.properties.mask_adult + '</span>個</h5><h5>兒童口罩: <span class="text-success h4 fw-900">' + item.properties.mask_child + '</span>個</h5></div></div>';
markers.addLayer(L.marker([lat, lng]).bindPopup(popupHTML));
});
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
});
</script>
</body>
</html>