-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_index_addData.html
55 lines (34 loc) · 1.49 KB
/
02_index_addData.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
<!-- **** #1: ADD THIS LINE after the Leaflet JS script in the <head> section **** -->
<!-- Add jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
// **** #2: ADD THIS SECTION ($.getJSON method) after Mapbox Streets tile layer in the <body> ****
// loading GeoJSON file - https://www.igismap.com/add-load-geojson-file-point-polyline-polygon-map-leaflet-js/
$.getJSON("Census_by_Community_2019.geojson",function(data){
// L.geoJson function is used to parse geojson file and load on to map
L.geoJson(data, {
style: polyStyle
}).addTo(mymap);
});
// **** #3: ADD THESE SECTIONS (colourBreaks() and polyStyle() functions) after $.getJSON ****
// Define colours based on data ranges (create choropleth map)
function colourBreaks(d) {
return d > 15000 ? '#b10026' :
d > 10000 ? '#e31a1c' :
d > 7000 ? '#fc4e2a' :
d > 5000 ? '#fd8d3c' :
d > 2500 ? '#feb24c' :
d > 1 ? '#fed976' :
'#525252';
}
// Style polygons and control opacity
function polyStyle(feature) {
return {
weight: 1,
fillColor: colourBreaks(feature.properties.res_cnt),
color: '#FFFFFF',
opacity: 1,
fillOpacity: 0.75
};
}
</script>