-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
217 lines (187 loc) · 6.99 KB
/
index.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- add a title for the overall map page here -->
<title>Lexington Housing Code Violations</title>
<!-- Mapbox js -->
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.3/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.3/mapbox.css' rel='stylesheet' />
<!-- Mapbox web GL -->
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.15.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.15.0/mapbox-gl.css' rel='stylesheet' />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- JQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- Latest compiled and minified Bootstrap -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!-- Mapbox version of Leaflet Markercluster -->
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/leaflet.markercluster.js'></script>
<link href='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.css' rel='stylesheet' />
<link href='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.Default.css' rel='stylesheet' />
<!-- Stamen Tiles -->
<!--<script src="http://maps.stamen.com/js/tile.stamen.js"></script>-->
<style>
html, body, #map {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
background-color: rgba(141, 158, 226, 0.6);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
background-color: rgba(0, 51, 160, 0.6);
}
.panel-fixed {
position: absolute;
bottom: 15px;
right: 15px;
margin-left: 60px;
width: 410px;
text-align: center;
z-index: 50;
}
.legend {
line-height: 18px;
color: #333333;
font-family: 'Open Sans', Helvetica, sans-serif;
padding: 6px 8px;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
.legend img {
width: 18px;
height: 18px;
float: left;
}
.legend p {
font-size: 12px;
line-height: 18px;
margin: 0;
}
</style>
</head>
<body>
<div class="panel group">
<div class="panel panel-primary panel-fixed">
<div class="panel-heading">
<h3 class="panel-title"><span class="title">Lexington Code Violations</span> <a data-toggle="collapse" href="#collapse1"><span class="glyphicon glyphicon-chevron-down"></span></a>
</h3>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
<span class="description"></span>
Lexington Code Enforcement Cases<br>
This map depicts the distribution of Housing Code Violation cases across all of Lexington-Fayette as well as providing information about the individual cases.<br>
The data for this map is available from <a href="http://www.civicdata.com/organization/lexington-ky">CivicData</a>.
</span>
</div>
</div>
</div>
</div>
<div id="map"></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiamVzc2licmVlbiIsImEiOiJGNnlGVkRrIn0.Ar8l7jFbPYG3SWR-DrTyNQ';
var baseLayer = new mapboxgl.Map({
//container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v8' //stylesheet location
/*center: [-74.50, 40], // starting position
zoom: 9 // starting zoom*/
});
// Add baselayer
// var baseLayer = new L.StamenTileLayer("toner-lite");
// Create Leaflet Control Object for Legend
var legend = L.control({position: 'bottomright'});
// Function that runs when legend is added to map
legend.onAdd = function (map) {
// Create Div Element and Populate it with HTML
var div = L.DomUtil.create('div', 'legend');
div.innerHTML += '<b>Violation Density</b><br />';
div.innerHTML += 'by Census Tract<br />';
div.innerHTML += '<small>Violations/100 Addresses</small><br />';
div.innerHTML += '<i style="background: #a50f15"></i><p>13+</p>';
div.innerHTML += '<i style="background: #de2d26"></i><p>10-13</p>';
div.innerHTML += '<i style="background: #fb6a4a"></i><p>7-10</p>';
div.innerHTML += '<i style="background: #fcae91"></i><p>3-7</p>';
div.innerHTML += '<i style="background: #fee5d9"></i><p>0-3</p>';
/*div.innerHTML += '<hr>Individual Violations';
div.innerHTML += '<br /><img src="images/rodent_open.png">Cited';
div.innerHTML += '<br /><img src="images/rodent.png">Corrected';*/
// Return the Legend div containing the HTML content
return div;
};
var dataLayer = null;
//add datalayer layer
$.getJSON("data/codenorm.geojson", function(data) {
dataLayer = L.geoJson(data, {style: style});
// Set function for color ramp
function setColor(density) {
return density > 13 ? '#a50f15' :
density > 10 ? '#de2d26' :
density > 7 ? '#fb6a4a' :
density > 3 ? '#fcae91' :
'#fee5d9';
};
// Set style function that sets fill color property equal to rodent density
function style(feature) {
return {
fillColor: setColor(feature.properties.hous100),
fillOpacity: 0.7,
weight: 2,
opacity: 1,
color: '#ffffff',
dashArray: '3'
}
};
});
//define the cluster layer
var markers = L.markerClusterGroup({
//spiderfyOnMaxZoom: false,
showCoverageOnHover: false,
});
//get geojson
$.getJSON("data/Violations.geojson", function(data) {
var geojson = L.geoJson(data, {
pointToLayer: function (feature, latlng) {
return L.circleMarker (latlng, {
radius: 4,
fillColor: "#2eb8b8",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
},
onEachFeature: function (feature, layer) {
/*// USE A CUSTOM MARKER
layer.setIcon(L.mapbox.marker.icon({'marker-symbol': 'circle-stroked', 'marker-color': '59245f'}));*/
//add popup
var props = layer.feature.properties;
layer.bindPopup("<b>" + "Address: " + "</b>" + props.Address + "<br>" + "<b>" + "Date Opened: " + "</b>" + props.DateOpened + "<br>" + "<b>" + "Outcome: " + "</b>" + props.Status);
}
});
markers.addLayer(geojson);
//add the map
var map = L.map('map', {maxZoom: 20}).fitBounds(markers.getBounds());
baseLayer.addTo(map);
dataLayer.addTo(map);
markers.addTo(map);
legend.addTo(map);
});
</script>
</body>
</html>