-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
354 lines (319 loc) · 11.3 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
<!DOCTYPE html>
<html lang='en'>
<head>
<title>JackBikes.org Tours</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="shortcut icon" href="favicon.ico">
<!-- load Bootstrap CSS for mobile devices -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" integrity="sha512-t4GWSVZO1eC8BM339Xd7Uphw5s17a86tIZIj8qRxhnKub6WoyhnrxeCIMeAqBPgdZGlCcG2PrZjMc+Wr78+5Xg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<!-- load jQuery -->
<script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://unpkg.com/esri-leaflet"></script>
<!-- load Font-Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<!-- load Leaflet.locatecontrol -->
<script src="https://cdn.jsdelivr.net/leaflet.locatecontrol/0.52.0/L.Control.Locate.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet.locatecontrol/0.52.0/L.Control.Locate.min.css"/>
<!-- load Leaflet-plugins to read GPX and KML -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/1.9.0/layer/vector/GPX.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/1.9.0/layer/vector/KML.min.js"></script>
<!-- Esri Leaflet Geocoder -->
<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder/dist/esri-leaflet-geocoder.css">
<script src="https://unpkg.com/esri-leaflet-geocoder"></script>
<!-- load leaflet-hash from local directory -->
<script src="src/leaflet-hash.js"></script>
<!-- load distance markers with geometry from local directory; see also style.css -->
<!-- <script src="src/leaflet.geometryutil.js" type="text/javascript"></script>
<script src="src/leaflet-distance-marker.js" type="text/javascript"></script> -->
<!-- load leaflet-sidebar from local directory -->
<link rel="stylesheet" href="src/L.Control.Sidebar.css" />
<script src="src/L.Control.Sidebar.js"></script>
<!-- load custom css -->
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<div id="map"></div>
<script>
var dropdownLocations = [
{
name: 'Select a bike tour and click marker/route',
coords: [40.1,-95.9],
zoom: 4
},
{
name: 'Vermont-Quebec 2024',
coords: [45.0, -73.35],
zoom: 7
},
{
name: 'Erie Canal 2024',
coords: [43.04, -74.81],
zoom: 7
},
{
name: 'Southern California 2024',
coords: [33.68, -118.01],
zoom: 7
},
{
name: 'Hartford CT to Burlington VT 2023',
coords: [43.47, -72.93],
zoom: 7
},
{
name: 'Palouse to Cascades Trail 2023',
coords: [47.19, -120.94],
zoom: 8
},
{
name: 'Portland OR to Walla Walla WA 2019',
coords: [45.749474, -120.532779],
zoom: 8
},
{
name: 'Hartford to Cambridge MA 2018',
coords: [42.275562,-71.9478181],
zoom: 8
},
{
name: 'Hartford to Cape Cod 2018',
coords: [41.817699,-71.6067407],
zoom: 8
},
{
name: 'Morrisville NY to Hartford CT 2017',
coords: [42.344784, -74.211066],
zoom: 8
},
{
name: 'South Florida loop 2017',
coords: [25.598192, -80.903098],
zoom: 8
},
{
name: "Le P'tit Train du Nord, Quebec 2015",
coords: [46.122481, -74.78],
zoom: 8
},
{
name: 'DC to Pittsburgh, C&O-GAP 2015',
coords: [39.65, -78.65],
zoom: 8
},
{
name: 'ECG Philadelphia to DC 2014',
coords: [39.281518, -76.461871],
zoom: 8
},
{
name: 'Portland Oregon Coast loop 2014',
coords: [45.3, -123.438121],
zoom: 8
},
{
name: 'Seattle-British Columbia loop 2014',
coords: [48.29, -122.64],
zoom: 8
},
{
name: 'Oberlin OH to Central NY 2012',
coords: [42.275605, -79.271988],
zoom: 7
},
];
var map = L.map('map', {
center: [40.1,-95.9],
zoom: 4,
zoomControl: false, // add later to reposition
scrollWheelZoom: false,
tap: false
});
var hash = new L.Hash(map);
map.attributionControl
.setPrefix("Download <a href='https://github.com/jackdougherty/bikemapcode' target='_blank'>Routes and Code on GitHub</a>, made with <a href='https://leafletjs.com' title='A JS library for interactive maps'>Leaflet</a>");
var controlLayers = L.control.layers( null, null, {
position: "topright",
collapsed: false
}).addTo(map);
// create the geocoding control, add to map, do NOT display results as markers
var searchControl = L.esri.Geocoding.geosearch({
position: 'topright'
}).addTo(map);
new L.control.zoom({position: "topright"}).addTo(map);
L.control.scale().addTo(map);
function disableMapInteractions() {
map._handlers.forEach(function(handler) {
handler.disable();
});
}
function enableMapInteractions() {
map._handlers.forEach(function(handler) {
handler.enable();
});
}
var dropdown = L.control({
position: 'topleft'
});
var EsriStreets = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri'
}).addTo(map);
function onEachFeature(feature, layer) {
var popupText = feature.properties.name
+ "<br><a href='" + feature.properties.desc +"' target='_blank'>Read blog post</a> (opens new tab)";
layer.bindPopup(popupText);
}
$.getJSON("routes/vermont-quebec-2024.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "green", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/erie-canal-2024.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "green", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/california2024.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "purple", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/vermont2023.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "purple", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/ptct-2023.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "black", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/pdx-ww2019.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "red", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/htfd-cambridge-2018.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "green", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/htfd-falmouth-2018.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "red", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/morrisville2017.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "blue", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/florida-tour-2017.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "blue", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/quebec2015.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "blue", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/COGAP2015.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "blue", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/ecg-philly-dc-2014.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "red", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/portland-or-loop-2014.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "blue", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/seattle-loop-2014.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "green", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
$.getJSON("routes/oberlin-cny-2012.geojson", function (data){
var geoJsonLayer = L.geoJson(data, {
style: {color: "red", weight: 3 },
onEachFeature: onEachFeature
}).addTo(map);
});
// Define flickrURL endpoint with API explorer: insert your key, and tags= or text= to filter results; increase limit to 500 images; pull geo and thumbnail, small, large image links and title
var flickrApiKey = '25dcc9a8c7410551dcb0af48c778bde5';
var flickrURL = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=' + flickrApiKey + '&user_id=56513965%40N06&tags=bikemap&per_page=500&extras=geo%2Curl_t%2Curl_s%2Curl_l%2Ctitle&format=json&nojsoncallback=1';
// Define the flickr popup display
var popupHTML = function(photo){
var result = '';
result = '<strong>'+photo.title+'</strong><br>';
result += '<a href="'+photo.url_l+'" target="_blank">';
result += '<img src="'+photo.url_s+'"></a>';
result += '<br/><small>click image to enlarge in new tab</small>';
return result;
}
// Load photos from flickr JSON (insert your flickrURL above), display with clickable photo thumbnails
$.getJSON(flickrURL, function (data) {
// Create new layerGroup for the markers, with option to append ".addTo(map);" to display by default
var layerGroup = new L.LayerGroup();
// Add layerGroup to your layer control and insert your label to appear in legend
controlLayers.addOverlay(layerGroup, 'Photos');
// Start a loop to insert flickr photo data into photoContent
for (var i = 0; i < data.photos.photo.length; i++) {
var photoContent = data.photos.photo[i];
var photoIcon = L.icon(
{iconUrl: photoContent.url_t,
iconSize: [photoContent.width_t * 0.5, photoContent.height_t * 0.5]} //reduces thumbnails 50%
);
var marker = new L.marker([photoContent.latitude, photoContent.longitude], {icon: photoIcon});
marker.bindPopup(popupHTML(photoContent));
// Add the marker to the layerGroup
marker.addTo(layerGroup);
}
});
function fly() {
disableMapInteractions();
var index = document.getElementById('dropdown').selectedIndex;
var place = dropdownLocations[index];
map.flyTo(place.coords, place.zoom);
map.on('zoomend', function() {
enableMapInteractions();
});
}
dropdown.onAdd = function(map) {
var div = L.DomUtil.create('div', 'dropdown-container');
var options = '';
for (i in dropdownLocations) {
options += '<option value=' + i + '>' + dropdownLocations[i].name + '</option>'
}
div.innerHTML = '<select id="dropdown" onchange="fly()">' + options + '</select>';
div.innerHTML += '<i class="fa fa-caret-down"></i>';
return div;
};
dropdown.addTo(map);
</script>
</body>
</html>