-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
399 lines (364 loc) · 17.4 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
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">-->
<!-- MapBox.js CSS -->
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css' rel='stylesheet' />
<!-- Photo Viewer CSS by Taylor Johnson (two required styles, can be further modified) -->
<link rel="stylesheet" href="photoViewer.css">
<!-- Twitter typeahead CSS by Bass Jobsen -->
<link href="typeaheadjs.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- jQuery Javascript -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- Bootstrap Latest compiled and minified JavaScript -->
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<!-- mapbox.js -->
<script type="text/javascript" src="https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js" ></script>
<!-- Photo Viewer JavaScript by Taylor Johnson (it usually works...) -->
<!-- <script type="text/javascript" src="photoViewer.js" async></script> -->
<!-- Twitter typeahead.js -->
<script type="text/javascript" src="typeahead.jquery.js"></script>
<title>Sandbar Monitoring Sites Demo</title>
<style>
#map {height:730px;}
</style>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-xs" href="http://www.gcmrc.gov/">USGS Grand Canyon Monitoring and Research Center</a>
<a class="navbar-brand visible-xs" href="http://www.gcmrc.gov/">USGS GCMRC</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<p class="navbar-text">Sandbar Monitoring Photographs</p>
<form class="navbar-form navbar-right" role="search">
<div class="input-group" id="searchBar">
<input type="text" class="form-control typeahead" placeholder="Search for sites...">
<span class="input-group-btn">
<button type="button" class="btn btn-default" id="search" aria-label="Search for sites" data-toggle="tooltip" data-placement="left" title="Search for sites">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-default" id="home" aria-label="Zoom map to full extent" data-toggle="tooltip" data-placement="left" title="Zoom to the Full Map Extent">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
</button>
</span>
</div>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li><a href="http://www.gcmrc.gov/">Home</a></li>
<li><a href="http://www.gcmrc.gov/research_areas/research_areas_default.aspx">Research Areas</a></li>
<li><a href="http://www.gcmrc.gov/research_areas/sediment_geomorphology/sed/Sed_Geomorph_Home_Page.aspx">Sediment and Geomorphology</a></li>
<li><a href="http://www.gcmrc.gov/sandbar/">Sandbar Monitoring</a></li>
<li class="active">Sandbar Monitoring Photographs</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3" id="sandSidebar">
<div class="well well-sm" style="overflow-y:scroll; height:750px;">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
</div>
</div>
</div>
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'></script>
<div class="col-md-9" id="mapDiv">
<div class="well well-sm">
<div id="map"></div>
</div>
</div>
</div>
</div>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<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>
</div>
<div class="modal-body">
<p>Photos coming soon...</p>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="imageModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<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" id="myModalLabel">Additional Images</h4>
</div>
<div class="modal-body row no-gutter">
<!-- First Carousel -->
<div id="image-carousel1" class="carousel slide" style="display: none;">
<!-- Indicators -->
<ol class="carousel-indicators">
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
</div>
<!-- Controls -->
<a class='left carousel-control' href='#image-carousel1' role='button' data-slide='prev'>
<span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span>
<span class='sr-only'>Previous</span>
</a>
<a class='right carousel-control' href='#image-carousel1' role='button' data-slide='next'>
<span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>
<span class='sr-only'>Next</span>
</a>
</div>
<!-- Second Carousel (Initially Hidden) -->
<div id="image-carousel2" class="carousel slide" data-interval="false" style="display: none;">
<!-- Indicators -->
<ol class="carousel-indicators">
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
</div>
<!-- Controls -->
<a class='left carousel-control' href='#image-carousel2' role='button' data-slide='prev'>
<span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span>
<span class='sr-only'>Previous</span>
</a>
<a class='right carousel-control' href='#image-carousel2' role='button' data-slide='next'>
<span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>
<span class='sr-only'>Next</span>
</a>
</div>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-default square pull-left' id='pauseGlyph' aria-label='Pause Photo Carousel'>
<span class='glyphicon glyphicon-pause'></span>
</button>
<button type='button' class='btn btn-default square pull-left' id='playGlyph' aria-label='Play Photo Carousel'>
<span class='glyphicon glyphicon-play'></span>
</button>
<button type='button' class='btn btn-default square pull-right' id='expandGlyph' aria-label='Expand Dual Photo Carousel'>
Dual Viewer <span class="glyphicon glyphicon-menu-right"></span>
</button>
<button type='button' class='btn btn-default square pull-right hidden' id='collapseGlyph' aria-label='Collapse Dual Photo Carousel'>
Dual Viewer <span class='glyphicon glyphicon-menu-left'></span>
</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
L.mapbox.accessToken='pk.eyJ1Ijoiam9obnNvbjd1Z2EiLCJhIjoiUDU1VXpCNCJ9.gL2i7S0K2hnw69L5xZlTug';
var map=L.mapbox.map('map', 'examples.map-i86nkdio');
var layer = omnivore.csv('locations.csv').addTo(map)
.on('error', function(error) {
console.log(error);
})
.on('ready', function(omLayer) {
this.eachLayer(function(marker) {
marker.setIcon(L.icon({
iconUrl: 'http://api.tiles.mapbox.com/mapbox.js/v2.1.5/images/marker-icon.png',
iconSize: [20, 32.8],
iconAnchor: [10, 32],
shadowUrl: 'http://api.tiles.mapbox.com/mapbox.js/v2.1.5/images/marker-shadow.png',
shadowSize: [40, 32.8],
popupAnchor: [0, -32]
}));
marker.bindPopup(marker.toGeoJSON().properties.Site_Name + ' ' +
'<button type="button" id="start" class="btn btn-primary btn-xs trigger" data-toggle="modal" data-target="#imageModal" data-site="'+ marker.toGeoJSON().properties.Site + '">View Photos</button>'
);
});
map.fitBounds(layer.getBounds());
var gLayer = layer.toGeoJSON(),
site_name, site_lat, site_lon, image_text, thumb_url, site, site_num,
searchSites = []; //declare variables outside the loop to avoid multiple declarations per loop iteration.
for (var i = 0, n = gLayer.features.length; i < n; i++) {
site_name = gLayer.features[i].properties.Site_Name;
site_lat = gLayer.features[i].geometry.coordinates[1].toString();
site_lon = gLayer.features[i].geometry.coordinates[0].toString();
image_text = gLayer.features[i].properties.Image_Text;
thumb_url = gLayer.features[i].properties.Thumb_URL;
site = gLayer.features[i].properties.Site;
site_num = i.toString();
searchSites.push(site_name);
$("#accordion").append(
'<div class="panel panel-default">' +
'<div class="panel-heading" role="tab" id="heading'+ site_num +'">'+
'<h4 class="panel-title">'+
'<a data-toggle="collapse" data-parent="#accordion" href="#collapse'+ site_num +'" aria-expanded="true" aria-controls="collapse'+ site_num +'">'+
site_name +
'</a>'+
'<span class="glyphicon glyphicon-map-marker" aria-hidden="true" style="float:right" data-location="' + site_lat + ',' + site_lon +'" data-toggle="tooltip" data-placement="right" title="Zoom to Location"></span>'+
'</h4>'+
'</div>'+
'<div id="collapse'+ site_num +'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'+ site_num +'">'+
'<div class="panel-body">'+
image_text + '<br>'+
'<img src="'+ thumb_url +'" alt="'+ site_name +'" class="img-thumbnail img-responsive center-block"><br>'+
'<button type="button" id="start" class="btn btn-primary trigger" data-toggle="modal" data-target="#imageModal" data-site="'+ site + '"style="float:right">View Photos</button>'+
'</div>'+
'</div>'+
'</div>'
);
}
//Activate Go Search button (not complete, Search button manual enabled for now
$('input[type="text"]').on('keyup', function() {
console.log($('input').val());
if (searchSites.indexOf($('input').val()) > -1) {
//$('button#search').removeAttr('disabled');
} else {
//$('button#search').attr('disabled', 'disabled');
}
});
//Go Search button
$('button#search').on('click', function(){
if (searchSites.indexOf($('input.tt-input').val()) > -1) {
map.setView([gLayer.features[searchSites.indexOf($('input.tt-input').val())].geometry.coordinates[1].toString(), gLayer.features[searchSites.indexOf($('input.tt-input').val())].geometry.coordinates[0].toString()], 15);
$('#collapse'+searchSites.indexOf($('input.tt-input').val()).toString()).collapse({parent:'.panel-group'});
$('#collapse'+searchSites.indexOf($('input.tt-input').val()).toString()).collapse('show');
$(location).attr('href', '#collapse'+searchSites.indexOf($('input.tt-input').val()).toString());
}
else {
alert("Please enter a valid site name to use search");
}
});
//typeahead code
var substringMatcher = function(strs) {
return function findMatches(q, cb) {
var matches = [], substrRegex = new RegExp(q, 'i');
$.each(strs, function(i, str) {
if (substrRegex.test(str)) {
matches.push({value: str});
}
});
cb(matches);
};
};
$('#searchBar .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'sites',
displayKey: 'value',
source: substringMatcher(searchSites)
});
//Site zoom button
$('.glyphicon-map-marker').on('click', function(){
map.setView($(this).data("location").split(","), 15, {animation: true});
});
//Launch photo viewer
$("#accordion, #map").on( "click", ".trigger", function(e) { //Use higher level selectors (to catch click events at higher level) and then pass a class trigger to focus the event handler function
var site_button = $(this).data("site");
console.log(site_button);
$.ajax({
type: "GET",
url: "photoCollection.xml",
dataType: "xml",
success: function(xml){
var $images = xml.getElementsByTagName("image"),
count = 0,
site,
url,
caption,
name;
$.each($images, function() {
site = $(this).find("site").text();
url = $(this).find("url").text();
caption = $(this).find("caption").text();
name = $(this).find("name").text();
if (site_button.toUpperCase() === site.toUpperCase()) {
if (count==0) {
$('#image-carousel1 .carousel-indicators').append('<li data-target="#image-carousel1" data-slide-to="0" class="active"></li>');
$('#image-carousel1 .carousel-inner').append('<div class="item active"><img src="'+url+'" alt="Image '+count+'"><div class="carousel-caption"><h4>'+name+'</h4></div></div>');
$('#image-carousel2 .carousel-indicators').append('<li data-target="#image-carousel2" data-slide-to="0" class="active"></li>');
$('#image-carousel2 .carousel-inner').append('<div class="item active"><img src="'+url+'" alt="Image '+count+'"><div class="carousel-caption"><h4>'+name+'</h4></div></div>');
}
else {
$('#image-carousel1 .carousel-indicators').append('<li data-target="#image-carousel" data-slide-to="'+count+'"></li>');
$('#image-carousel1 .carousel-inner').append('<div class="item"><img src="'+url+'" alt="Image '+count+'"><div class="carousel-caption"><h4>'+name+'</h4></div></div>');
$('#image-carousel2 .carousel-indicators').append('<li data-target="#image-carousel2" data-slide-to="'+count+'"></li>');
$('#image-carousel2 .carousel-inner').append('<div class="item"><img src="'+url+'" alt="Image '+count+'"><div class="carousel-caption"><h4>'+name+'</h4></div></div>');
}
count++;
}
});
}
});
});
// Reset the carousel(s) in the modal once the modal closed
$("#imageModal").on("hidden.bs.modal", function(){
$('#image-carousel1').carousel('pause');
$('#image-carousel2').carousel('pause');
$('#image-carousel1').hide();
$('#image-carousel2').hide();
$('#image-carousel1').removeClass('col-xs-6');
$('#image-carousel2').removeClass('col-xs-6');
$('.modal-dialog').removeClass('dual');
$('#collapseGlyph').addClass('hidden');
$('#expandGlyph').removeClass('hidden');
$(".carousel-indicators").empty();
$(".carousel-inner").empty();
});
// Only show the carousel when the modal is shown
$('#imageModal').on('show.bs.modal', function(){
$('#image-carousel1').show();
$('#image-carousel1').carousel({interval: 4000}); // Set the carousel interval here (in milliseconds). The second carousel is set to not auto-rotate
});
// Pause button for the initial carousel
$('#pauseGlyph').click(function(){
$('#image-carousel1').carousel('pause');
});
// Play button for the intial carousel (automatically increments to next slide)
$('#playGlyph').click(function(){
$('#image-carousel1').carousel('next');
$('#image-carousel1').carousel('cycle');
});
// Enable dual photo viewer (changes the appearance of the modal so carousels are always side-by-side by adding the dual class which sets the width to 95% of the screen)
$('#expandGlyph').click(function(){
$(this).addClass('hidden');
$('#collapseGlyph').removeClass('hidden');
$('#image-carousel1').addClass('col-xs-6');
$('#image-carousel2').addClass('col-xs-6');
$('.modal-dialog').addClass('dual');
$('#image-carousel2').show();
});
// Disables dual photo viewer
$('#collapseGlyph').click(function(){
$(this).addClass('hidden');
$('#expandGlyph').removeClass('hidden');
$('#image-carousel1').removeClass('col-xs-6');
$('#image-carousel2').removeClass('col-xs-6');
$('.modal-dialog').removeClass('dual');
$('#image-carousel2').hide();
});
});
//Zoom/pan map to full extent
$('#home').on('click', function() {
map.fitBounds(layer.getBounds());
});
});
</script>
</body>