-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
147 lines (134 loc) · 5.75 KB
/
index.html
File metadata and controls
147 lines (134 loc) · 5.75 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Philly Cycle Trips Map</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://maps.stamen.com/js/tile.stamen.js?v1.2.4"></script>
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css' rel='stylesheet' />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
ul.scroll-menu {
overflow-y: auto;
-webkit-overflow-scrolling: touch;
-moz-overflow-scrolling: touch;
-ms-overflow-scrolling: touch;
-o-overflow-scrolling: touch;
overflow-scrolling: touch;
width:175px;
height: auto;
max-height: 400px;
}
#layers { position:relative; float:right; top:15px; right:15px; font-size:12px;
z-index:999; font-weight:bold; }
.Commute { background-color:#256baf; }
.School { background-color:#dfdeb6; }
.Exercise { background-color:#16ac69; }
.Social { background-color:#ccd93e; }
.Other { background-color:#698ea2; }
.Work-Related { background-color:#0a5983; }
.Errand { background-color:#99cccc; }
.Shopping { background-color:#2487bc; }
</style>
</head>
<body>
<div class="btn-group btn-group-lg pull-right">
<div id="layers" class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" type="button"
id="dropdownMenu" data-toggle="dropdown">Layers <span class="caret"></span>
</button>
<ul id='map-ui' class="scroll-menu list-group dropdown-menu nav nav-pills nav-stacked" role="menu" aria-labelledby="dropdownMenu">
</ul>
</div>
</div>
<div id='map'></div>
<script>
var ui = document.getElementById('map-ui');
var map = L.map('map', {
tileLayer: {
detectRetina: true
}
}).setView([39.952451,-75.163664], 13);
L.control.layers.autoZIndex = true;
addLayer(L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png', { attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.' }), null, 'Base Map', 1, null);
addLayer(L.mapbox.tileLayer('banderkat.philly_bikeroutes', {attribution:'Data from City of Philadelphia'}),
L.mapbox.gridLayer('banderkat.philly_bikeroutes'), 'Bike Routes', 2, null);
addLayer(L.tileLayer('http://banderkat.com:8888/v2/bike-circuit/{z}/{x}/{y}.png', {attribution:'Data from DVRPC'}),
L.mapbox.gridLayer('http://banderkat.com:8888/v2/bike-circuit.json'),
'The Circuit', 3, null);
addCyclePhillyLayer('Commute');
addCyclePhillyLayer('School');
addCyclePhillyLayer('Exercise');
addCyclePhillyLayer('Social');
addCyclePhillyLayer('Other');
addCyclePhillyLayer('Work-Related');
addCyclePhillyLayer('Errand');
addCyclePhillyLayer('Shopping');
function addCyclePhillyLayer(purpose) {
addLayer(L.tileLayer('http://54.165.29.118/tiles/' + purpose +
'/{z}/{x}/{y}.png',
{attribution:'CyclePhilly'}),
L.mapbox.gridLayer('http://54.165.29.118/tiles/' + purpose + '.json'),
purpose, null);
}
function addLayer(layer, infoLayer, name, zIndex, color) {
var gridControl = null;
layer.addTo(map);
if (zIndex == 1) {
layer.bringToBack(); // keep base layer at bottom
}
if (infoLayer) {
infoLayer
.addTo(map);
gridControl = L.mapbox.gridControl(infoLayer, {follow: true}).addTo(map);
}
// Create a simple layer switcher that toggles layers on
// and off.
var item = document.createElement('li');
var link = document.createElement('a');
link.href = '#';
link.className = 'active pull-right nav-justified';
link.innerHTML = '<span class="badge pull-left approved ' + name +
'"><span class="glyphicon glyphicon-ok"></span></span><span class="pull-right">' +
name + '</span>';
item.setAttribute('role', 'presentation');
item.className = 'nav-justified';
link.setAttribute('role', 'menuitem');
link.tabindex = '-1';
link.onclick = function(e) {
e.preventDefault();
e.stopPropagation();
if (map.hasLayer(layer)) {
map.removeLayer(layer);
if (infoLayer) {
map.removeLayer(infoLayer);
gridControl.hide(); // hide any tooltip currently showing
map.removeControl(gridControl);
}
this.className = 'pull-right layeritem nav-justified';
this.innerHTML = '<span class="pull-right">' + name + '</span>';
} else {
map.addLayer(layer);
if (infoLayer) {
map.addLayer(infoLayer);
map.addControl(gridControl);
}
this.className = 'active pull-right layeritem nav-justified';
this.innerHTML = '<span class="badge pull-left approved ' + name +
'"><span class="glyphicon glyphicon-ok"></span></span><span class="pull-right">' +
name + '</span>';
}
};
item.appendChild(link);
ui.appendChild(item);
}
$('ul.scroll-menu').css('max-height', $(window).height() - 120);
</script>
</body>
</html>