-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
273 lines (261 loc) · 9.47 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>ARC Planning Areas</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css' rel='stylesheet' />
<!-- <script src='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.css' rel='stylesheet' /> -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css"/>
<!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> -->
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.4/Leaflet.fullscreen.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.4/leaflet.fullscreen.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.css' rel='stylesheet' />
<link href='https://fonts.googleapis.com/css?family=PT+Serif:700' rel='stylesheet' type='text/css'>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
#panel {
/*opacity:.6;*/
margin: 6px 8px;
padding: 6px 8px;
position: fixed;
right:0px;
background-color:white;
z-index: 1000;
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.switches {
margin-top:15px;
text-align: center;
width: inherit;
display: inline-block;
}
.boundary-checkbox{
min-width: 320px;
}
.county-label{
background: rgba(0,0,0,0);
border: none;
padding: 0px;
font-family: 'PT Serif', serif;
font-size: large;
text-shadow:
-1px -1px 0 #fff,
1px -1px 0 #fff,
-1px 1px 0 #fff,
1px 1px 0 #fff;
z-index: -1000;
}
.leaflet-label:before{
border: none;
}
</style>
</head>
<body>
<div id="panel" class="pull-right">
<div class="form-group">
<h4>
ARC Planning Areas
<button class="btn btn-default btn-xs" data-toggle="modal" data-target="#aboutModal">
Help
</button>
</h4>
<div id="boundarySelect" class="text-left" style="width:330px" >
</div>
</div>
</div>
<div id='map'></div>
<div id="aboutModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">ARC Planning Areas</h4>
</div>
<div class="modal-body">
This map shows the various boundaries within which the Atlanta Regional Commission operates.
<ul id="boundaryList">
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<script>
boundaryMap = {
"RDC_AAA":{
"name":"Regional Commission",
"description":"Facilitates intergovernmental coordination and provide comprehensive planning assistance and other services to constituent jurisdictions.",
"color": "#0000ff",
"dash": "3, 6",
"btn": "btn-primary"
},
"8hr_NA":{
"name":"Ozone Non-attainment Area (8-hr)",
"description":"Performs required technical analysis to demonstrate conformity to Ozone requirements.",
"color": "#11bf11",
"dash": "3, 6",
"btn": "btn-success"
},
"MPO Area Actual":{
"name":"Metropolitan Planning Organization",
"description":"Responsible for carrying out the federally required metropolitan transportation planning process.",
"color": "#ff9a00",
"dash": 6,
"btn": "btn-warning"
},
"Particulate Matter":{
"name":"Particulate Matter Maintenance Area",
"description":"Performs required technical analysis to demonstrate conformity to PM requirements.",
"color": "#f00000",
"dash": 0,
"btn": "btn-danger"
},
};
// <label class="btn btn-primary active">
// <input type="checkbox" autocomplete="off" checked> Checkbox 1 (pre-checked)
// </label>
L.mapbox.accessToken = 'pk.eyJ1IjoibGNhY2VkYSIsImEiOiIzNmM4MGRlN2I4NDhiY2UxZjA4MmJjZjE5OWEzYjUzNSJ9.Wc5KTJpWxmpxVMZfcuEQNg';
var map = L.mapbox.map('map')
.setView([33.81908916394128, -84.04403686523438], 9)
.addLayer(L.mapbox.styleLayer('mapbox://styles/lcaceda/ckhvg8oj907om19mojygoda2x'));
L.control.fullscreen().addTo(map);
var geojson;
var geojsonData;
var counties;
var slice;
var labels = [];
var defaultStrokeOpacity = 1;
var boundaryWeight = 0;
var countyWeight = 2;
var defaultFillOpacity = 0.5;
$.each(boundaryMap, function(key, value){
$('#boundarySelect').append('<label class="boundary-checkbox btn ' +
value.btn +
' active">' +
'<input class=" pull-left" type="checkbox" autocomplete="off" checked value="' + key + '"> ' +
'<span class="pull-left" style="padding:0 0 0 4px"> ' + value.name + '</span>' + // ' <button class="btn btn-xs"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></button>' +
'</label>'
);
$('#boundaryList').append('<li><strong>' + value.name + '</strong> - ' + value.description + '</li>' )
});
$('#boundarySelect').append('<label class="boundary-checkbox btn btn-default"><input class=" pull-left" type="checkbox" autocomplete="off" checked value="counties"><span class="pull-left" style="padding:0 0 0 4px"> Counties</span></label>')
$('label > input[type=checkbox]').on('change', function () {
// console.log();
var checked = $(this).is(':checked');
console.log(this.value);
// console.log(geojson.getLayers());
var layers = geojson.getLayers();
if (checked){
for (var i = 0; i < layers.length; i++) {
if (layers[i].feature.properties.REGION === this.value){
// layers[i].setStyle({opacity:defaultStrokeOpacity,fillOpacity:defaultFillOpacity});
map.addLayer(layers[i]);
orderLayers();
}
};
}
else {
for (var i = 0; i < layers.length; i++) {
if (layers[i].feature.properties.REGION === this.value){
// layers[i].setStyle({opacity:0,fillOpacity:0});
map.removeLayer(layers[i]);
}
};
}
if (this.value === 'counties'){
if (checked){
map.addLayer(counties);
counties.bringToBack();
for (var i = 0; i < labels.length; i++) {
map.addLayer(labels[i])
};
}
else{
map.removeLayer(counties);
for (var i = 0; i < labels.length; i++) {
map.removeLayer(labels[i])
};
}
}
});
// Get Planning Areas
// geojson query only selects 4 needed planning areas.
$.getJSON("https://opendata.arcgis.com/datasets/00291eb4d3e34cb8bc642919a91a9e72_99.geojson", function(data){
geojsonData = data;
console.log(data);
geojson = L.geoJson(data, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
orderLayers();
});
// Get COUNTIES
$.getJSON('https://opendata.arcgis.com/datasets/53ca7db14b8f4a9193c1883247886459_67.geojson', function(data){
// coun = data;
$.each(data.features, function(i, feature){
// console.log(feature);
if (typeof feature === 'undefined'){
console.log('county undefined');
// geojsonData.features.splice(i, 1);
data.features.splice(i, 1);
}
if (i === data.features.length - 1){
counties = L.geoJson(data, {
style: {
opacity: 1,
color: 'black',
fillOpacity: 0,
weight: countyWeight,
dashArray: "5,2,3,7"
}
// onEachFeature: onEachCounty
}).addTo(map)
}
});
});
function style(feature){
return {
fillColor: typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? boundaryMap[feature.properties.REGION].color : '#fff',
weight: boundaryWeight,
opacity: typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? defaultStrokeOpacity : 0,
fillOpacity: typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? defaultFillOpacity : 0,
color: typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? boundaryMap[feature.properties.REGION].color : '#fff',
dashArray: typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? boundaryMap[feature.properties.REGION].dash : 3,
};
}
function onEachFeature(feature, layer){
var popupContent = typeof boundaryMap[feature.properties.REGION] !== 'undefined' ? '<h4>' + boundaryMap[feature.properties.REGION].name + '</h4><p>' + boundaryMap[feature.properties.REGION].description + '</p>' : '' ;
if (typeof boundaryMap[feature.properties.REGION] !== 'undefined') {
layer.bindPopup(popupContent);
}
}
function orderLayers(){
var layers = geojson.getLayers();
layers[1].bringToFront();
layers[3].bringToFront();
layers[0].bringToFront();
}
function onEachCounty(feature, layer){
var xOffset = -feature.properties.NAME10.length * feature.properties.NAME10.length / 2
var label = new L.Label({
className:'county-label',
offset:[xOffset,-5]
})
label.setContent(feature.properties.NAME10)
label.setLatLng(layer.getBounds().getCenter())
labels.push(label);
map.showLabel(label);
}
</script>
</body>
</html>