-
Notifications
You must be signed in to change notification settings - Fork 0
/
Recovered_D.html
176 lines (155 loc) · 6.01 KB
/
Recovered_D.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<html>
<head>
<title>COVID19 Map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
#map{
height: 100%;
width: 100%;
margin: 0;
}
.info {
line-height: 30px;
padding: 6px 8px 10px 12px;
font: 16px/18px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
margin:20px;
overflow: auto;
text-height: 5px;
}
.info h3 {
margin: 0 0 5px;
color: #777;
}
.legend {
padding: 15px;
width: 120px;
line-height: 18px;
color: #555;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
margin-bottom: 40px;
}
.legend i {
padding: 2px;
width: 15px;
height: 15px;
display:inline-block;
margin-right: 8px;
opacity: 0.7;
}
.leaflet-tile-container{
opacity:0.5;
}
p{
color:green;
margin:0%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// initialize the map
var mymap = L.map('map').setView([28.35,83.962], 7);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoic2hyZXN0aGFzaG9rNTUwIiwiYSI6ImNrYXRtM3E5azBpcG4ycnB0ZjEwam96dGYifQ.gRE7aJ_Lf9ZCz64WiUulwQ'
}).addTo(mymap);
// load GeoJSON from an external file
$.getJSON("District.geojson",function(data){
// add GeoJSON layer to the map once the file is loaded
function getColor(d) {
return d > 200 ? '#00441b' :
d > 150 ? '#006d2c' :
d > 100 ? '#238b45' :
d > 50 ? '#41ae76' :
d > 25 ? '#66c2a4' :
d > 10 ? '#99d8c9' :
d > 5 ? '#ccece6' :
d > 0 ? '#e5f5f9' :
'#f7fcfd' ;
}
function style(feature) {
return {
fillColor: getColor(feature.properties.Recovered),
weight: 2,
opacity: 1,
color: 'blue',
dashArray: '3',
fillOpacity: 1
};
}
var info = L.control({position: 'topright'});
info.onAdd = function (mymap) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '<h3>Recovered</h3>' + (props ?
'<b>' + 'Province:'+props.Province + '</b><br />' +'<b>' + props.DISTRICT + '</b><br />' + props.District_N + '<br />' + '<p>'+'Recovered: '+ props.Recovered+'</p'
: 'Hover over a District');
};
info.addTo(mymap);
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
function onEachFeature(feature, layer) {
layer.bindTooltip(feature.properties.District_N +'</br>' +'<p>'+'Recovered: ' + feature.properties.Recovered+'</p');
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
});
}
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (mymap) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 5, 10, 25, 50, 100, 150, 200],
labels = ['<strong>Recovered </strong>'];
// loop through our density intervals and generate a label with a colored square for each interval
for (var i = 0; i < grades.length; i++) {
labels.push(
'<i style="background:' + getColor(grades[i] + 1) + '"></i> ' +
grades[i] + (grades[i + 1] ? '–' + grades[i + 1] : '+'));
}
div.innerHTML=labels.join('<br>');
return div;
};
legend.addTo(mymap);
geojson = L.geoJson(data, {
style: style,
onEachFeature: onEachFeature
}).addTo(mymap);
});
</script>
</body>
</html>