forked from blueaccounting/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErieStat_Map_tabs.html
335 lines (288 loc) · 10.8 KB
/
ErieStat_Map_tabs.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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spring SRP Loading in ErieStat Watersheds</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css">
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://unpkg.com/esri-leaflet@2.1.3/dist/esri-leaflet.js"></script>
<script src="//code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!--<!– Optional theme –>-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!--<!– Latest compiled and minified JavaScript –>-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/ba_chart2.js"></script>
<script src="js/export-csv_glc.js"></script>
<link rel="stylesheet" href="css/BA_Style.css">
</head>
<body>
<style>
/*.label div {*/
/*color: black;*/
/*position: relative;*/
/*left: -70%;*/
/*font-size: 12px;*/
/*font-style: italic;*/
/*!*text-shadow: 0px 2px 1px rgba(255,255,255,0.85);*!*/
/*}*/
/*#legend {*/
/*z-index: 99;*/
/*position: absolute;*/
/*padding: 15px;*/
/*margin-bottom: 5%;*/
/*left: 10px;*/
/*bottom: 5%;*/
/*height: 20px;*/
/*width: 100px;*/
/*background: rgba(255, 255, 255, 0.8);*/
/*color: black;*/
/*}*/
/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons that are used to open the tab content */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
.tabcontent {
animation: fadeEffect 1s; /* Fading effect takes 1 second */
}
/* Go from zero to full opacity */
@keyframes fadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
/* Style the close button */
.topright {
float: right;
cursor: pointer;
font-size: 28px;
}
</style>
<div>
<div id="map"></div>
<!--<div id="legend">Legend here</div>-->
<div class="vl"></div>
<div id="right-panel">
<div id="intro"></div>
<div id="narrative-section">
<p id="narrative-caption"></p>
<p id="narrative-content"></p>
</div>
<!-- Tab links -->
<div class="tab">
<button class="tablinks" onclick="openFractionChart(event, 'SRP')" id="defaultOpen">SRP (and more text can be placed in here)</button>
<button class="tablinks" onclick="openFractionChart(event, 'TP')">TP</button>
<button class="tablinks" onclick="openFractionChart(event, 'Another tab')">More tabs (Placeholder)</button>
</div>
<!-- Tab content -->
<div id="SRP" class="tabcontent">
<span onclick="this.parentElement.style.display='none'" class="topright">×</span>
<div id="chart1"></div>
<!--<h3>London</h3>-->
<!--<p>London is the capital city of England.</p>-->
</div>
<div id="TP" class="tabcontent">
<span onclick="this.parentElement.style.display='none'" class="topright">×</span>
<div>
<div id="chart2"></div>
</div>
<!--<h3>Paris</h3>-->
<!--<p>Paris is the capital of France.</p>-->
</div>
<div id="Another tab" class="tabcontent">
<span onclick="this.parentElement.style.display='none'" class="topright">×</span>
<h3>Title</h3>
<p>Contents go here</p>
</div>
<!--<div id="lowerCanvas">-->
<!--<div id="lowerChart"></div>-->
<!--</div>-->
</div>
</div>
<script>
var data;
var serviceURL = "https://gis.glc.org/server/rest/services/ErieStat/SpringSRP/MapServer";
var metric = metrics.SRP_L_S;
init();
$.getJSON("data/all_data2.json", function(d){
data = d;
});
var map = L.map("map").setView([42.1, -83.1], 8);
L.esri.basemapLayer("Topographic").addTo(map);
var watersheds = L.esri.dynamicMapLayer({
url: serviceURL,
layers:[0, 1, 2],
f: "image",
opacity: 0.7
}).addTo(map);
var boundary_query = L.esri.query({
url: serviceURL + "/0"
});
boundary_query.bounds(function(error, latlngbounds){
map.fitBounds(latlngbounds);
});
// var query = L.esri.query({
// url: 'https://gis.glc.org/server/rest/services/ErieStat/PriorityWatersheds/MapServer/1'
// });
var selectedFeature;
map.on("click", function (e){
if(selectedFeature){
map.removeLayer(selectedFeature);
}
watersheds.identify().on(map).at(e.latlng).layers("visible:1").simplify(map, 0.5).run(function (error, featureCollection){
if(featureCollection.features.length >0){
$("#intro").css("visibility", "hidden");
$(".tab").css("display", "block");
document.getElementById("defaultOpen").click();
for(var i = 0; i < featureCollection.features.length; i++){
selectedFeature = L.geoJSON(featureCollection.features[i]);
selectedFeature.setStyle({
fill: false,
weight: 4,
// color: "#07fcf0"
color: "#F3A51E"
});
selectedFeature.addTo(map);
var name = featureCollection.features[i].properties["Watershed Name"];
buildNarratives(name);
var temp = window.innerHeight - $("#narrative-section").height() - 300;
buildChart(data, "chart1", name, metric, units[metric], null, (window.innerHeight - $("#narrative-section").height()) * 0.8);
buildChart(data, "chart2", name, metrics.TP_L, units[metrics.TP_L], null, (window.innerHeight - $("#narrative-section").height()) * 0.8);
// query.where("MergeNm='"+ name +"'").bounds(function(error, latLngBounds, response){
// map.fitBounds(latLngBounds);
// });
break;
}
}
})
});
function init(){
// Hide tabs
var tabs = document.getElementsByClassName("tab");
for (i = 0; i < tabs.length; i++) {
tabs[i].style.display = "none";
}
// Show intro
$("#intro").html(intro_SRP);
};
function openFractionChart(evt, fraction) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
tablinks[i].id = "";
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(fraction).style.display = "block";
evt.currentTarget.className += " active";
// Maintain current tab open
evt.currentTarget.id = "defaultOpen";
}
// $.ajax({
// url: serviceURL + "/legend?f=json",
//
// }).then(function(legendJson){
// var content = "<br>";
// var json = JSON.parse(legendJson);
// for(var i = 0; i < json.layers.length; i++){
//
// }
// var j = legendJson;
//
// });
/*****
* Section added for labels
*/
// var labels = {};
// var pilotWatersheds = L.esri.featureLayer({
// url: 'https://gis.glc.org/server/rest/services/ErieStat/PriorityWatersheds/MapServer/1',
// style: function(feature){
// return {
// opacity: 0,
// fill: false
// }
// }
// }).addTo(map);
// pilotWatersheds.on('createfeature', function(e){
// var id = e.feature.id;
// var feature = pilotWatersheds.getFeature(id);
// var center = feature.getBounds().getCenter();
// var label = L.marker(center, {
// icon: L.divIcon({
// iconSize: null,
// className: 'label',
// html: '<div>' + e.feature.properties.MergeNm + '</div>'
// })
// }).addTo(map);
// labels[id] = label;
// });
// pilotWatersheds.on('addfeature', function(e){
// var label = labels[e.feature.id];
// if(label){
// label.addTo(map);
// }
// });
//
// pilotWatersheds.on('removefeature', function(e){
// var label = labels[e.feature.id];
// if(label){
// map.removeLayer(label);
// }
// });
/***
* End of section
* */
// function findFeatureLayer(featureCol){
// for(var i = 0; i < featureCol.features.length; i++){
// if(featureCol.features[i].layerId == 1){
// var name = featureCol.features[i].properties["Watershed Name"];
// buildChart("upperChart", name);
// buildNarratives(name);
// query.where("MergeNm='"+ name +"'").bounds(function(error, latLngBounds, response){
// map.fitBounds(latLngBounds);
// });
// return i;
// }
// }
// return null;
// }
</script>
</body>
</html>