-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbusRoute.html
152 lines (141 loc) · 5.1 KB
/
busRoute.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Busroute from CSV</title>
<script src="js/polymaps.min.js" type="text/javascript"></script>
<script src="js/jquery-1.7.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="js/date.js" type="text/javascript"></script>
<link type="text/css" href="css/humanity/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body,html{
padding: 0;
margin: 0;
}
path{
fill: none;
stroke-width: 4;
}
circle{
fill: none;
}
h1,h2,h3,h4,h5,p,a,span{
font-family: "Trebuchet MS",Verdana,Helvetica,Arial,sans-serif;
}
#container{
height: 100%;
}
#map {
width: 79%;
border: 1px solid #666;
float: left;
position: static;
}
#sidebar{
width: 19%;
margin: 0.5%;
height: auto;
float: left;
}
#slider{
margin-top: 5px !important;
}
/* Slider resizing */
.ui-slider-horizontal{
height: 5px !important;
}
.ui-slider-handle{
height: 10px !important;
border-radius: 0px !important;
top: -0.2em !important;
}
</style>
</head>
<body>
<div id="container">
<div id="sidebar">
<h3>Chennai Congestion Map</h3><p>Based on Bus Speed Data</p>
<p><span style="font-size: 0.8em;">Move the slider to select a time frame</span></p>
<div id="slider"></div>
<div style="margin-top: 5px; border: 1px solid #9CD; padding:3px;">
<p style="font-size: 0.8em;">Time-frame: <span id="slide-tip"></span></p>
</div>
<div class="ui-state-highlight ui-corner-all" style="margin-top: 10px; padding:10px;">
<p style="font-size: 0.7em;"><span class="ui-icon ui-icon-info" style="float:left;"></span>
This map has been created with a test data of the GPS Log data from the MTC [Metropolitan Transport Corporation (Chennai)]
The background tiles are served using <a href="http://www.cloudmade.com">Cloudmade</a> web application tiles.
This is written using the <a href="http://www.polymaps.org">Polymaps</a> javascript library.
</p>
</div>
</div>
<div id="map"></div>
</div>
<script type="text/javascript">
// Map code
var po = org.polymaps;
// lat=13.01268&lon=80.236362&zoom=15
// 13.098159,80.16945
var map = po.map()
.container(document.getElementById('map').appendChild(po.svg("svg")))
.center({ lat: 13.16159, lon: 80.16945 })
.zoom(12)
.zoomRange([12,15])
.add(po.interact());
map.add(po.image()
.url(po.url("http://{S}tile.cloudmade.com"
+ "/d2126e5f6bd740079852c1ee3a900d68"
+ "/998/256/{Z}/{X}/{Y}.png")
.hosts(["a.", "b.", "c.", ""])));
function showPath(hour, previous){
var url2="path.php?";
if(hour.toString().split(".").length > 1){url2 = url2+"hour="+Math.floor(hour)+"&min=30";}
else{url2=url2+"hour="+hour+"&min=00";}
var layer = po.geoJson()
.url(url2)
.zoom(12)
.tile(false)
.on("load", po.stylist()
.attr("stroke", function(l){
if(l.properties.speed < 10){ return "black";}
else if ((l.properties.speed > 10) && (l.properties.speed < 20)){ return "red"}
else if ((l.properties.speed > 20) && (l.properties.speed < 30)){ return "yellow"}
else if (l.properties.speed > 30){ return "green"}
}));
if (previous != undefined){
map.remove(previous);
}
map.add(layer);
return layer;
}
var nowShowing;
// Slider Code
function formatTime(value){
function pad(val){return (val < 10)?0+val.toString():val.toString();}
function tohrs(str){ return (str.split(".").length > 1)?str.split(".")[0]+"30":str+"00";}
return "<i>"+tohrs(pad(value))+" to "+tohrs(pad(value+0.5))+" hrs</i>";
}
$(function(){
$(window).resize(function(){
$("#map").height($(window).height() - 5);
});
$("#slider").slider({
value:8,
min: 0,
max: 23,
step: 0.5,
slide: function(event, ui){
$("#slide-tip").html(formatTime(ui.value));
nowShowing = showPath(ui.value, nowShowing);
}
});
$("#slide-tip").html("0800 to 0830 hrs");
$('#map').height($(document).height()-5);
});
</script>
</body>
</html>