-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathleafletAdd.html
103 lines (80 loc) · 2.47 KB
/
leafletAdd.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
<!DOCTYPE html>
<html>
<head>
<title>vornoi</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<style>
#map {
width: 100%;
height: 1000px;
}
.info {
padding: 6px 8px;
font: 14px/16px 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;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
.legend {
text-align: left;
line-height: 18px;
color: #555;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
</style>
</style>
</head>
<body>
<div id="map"></div>
<!--here is the reference the call to the geojson that I converted to js - if you look at this file- you will see I named the var
TFDpoly can you find that later in this code? replace that with your variable name -->
<script type="text/javascript" src="http://faculty.washington.edu/bricker0/js/TFDvor.js"></script>
<script>
var map = L.map('map').setView([ 47.2414, -122.4594], 12);
L.tileLayer('http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: 'abcd',
}).addTo(map);
//add the geoJson file but no style
// L.geoJson(TFDpoly).addTo(map);
/// get color depending on YTD_Count which represents number of calls in the grid cell - first set color scheme
function getColor(d) {
return d > 12 ? '#800026' :
d > 10 ? '#BD0026' :
d > 8 ? '#E31A1C' :
d > 6 ? '#FC4E2A' :
d > 4 ? '#FD8D3C' :
d > 2 ? '#FEB24C' :
d > 0 ? '#FED976' :
'#FFEDA0';
}
//styling the GeoJSON so that fill changes with the value associated with the cell and number of calls
function style(feature) {
return {
weight: 1,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7,
fillColor: getColor(feature.properties.Input_FID)
};
}
L.geoJson(TFDpoly, {style: style}).addTo(map);
map.on('click', onMapClick);
</script>
</body>
</html>