-
Notifications
You must be signed in to change notification settings - Fork 152
/
cabspotting.html
73 lines (66 loc) · 2.64 KB
/
cabspotting.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
<html>
<head>
<title>Modest Maps JS</title>
<script type="text/javascript" src="../../modestmaps.js"></script>
<script type="text/javascript" src="../cloudmade/cloudmade.js"></script>
<script type="text/javascript" src="cab-follower.js"></script>
<script type="text/javascript">
var map;
function initMap() {
// "import" the namespace
// please use your own API key, see http://developers.cloudmade.com/ for more details
var provider = new MM.Layer(new MM.CloudMadeProvider('1a914755a77758e49e19a26e799268b7','999'));
map = new MM.Map('map', provider, new MM.Point(640,480))
map.setCenterZoom(new MM.Location(37.774, -122.422), 11);
loadYQL("http://cabspotting.org/cabs.xml.php", 'cablist');
}
function loadYQL(url, callback) {
var yqlURL = 'http://query.yahooapis.com/v1/public/yql';
var yqlArgs = {
q: 'select * from xml where url="'+url+'"',
format: 'json',
callback: callback
};
var queries = [];
for (var prop in yqlArgs) {
queries.push(prop + '=' + yqlArgs[prop]);
}
var script = document.createElement('script');
script.src = yqlURL + '?' + queries.join('&');
document.getElementsByTagName('head')[0].appendChild(script);
}
function cablist(data) {
if (data && data.query && data.query.results) {
var cabs = data.query.results.cabs;
if (cabs && cabs.cab) {
for (var i = 0; i < cabs.cab.length; i++) {
var cabURL = 'http://cabspotting.org/cab.xml.php?cab=' + cabs.cab[i].id;
loadYQL(cabURL, 'plotcab');
}
}
}
}
function plotcab(data) {
//console.log(data);
if (data && data.query && data.query.results) {
var cab = data.query.results.cab;
if (cab && cab.point) {
// add cab viz
var points = cab.point;
if (points.length && points.length > 0) {
var location = new com.modestmaps.Location(points[0].lat, points[0].lon);
new com.modestmaps.CabFollower(map, location, points[0].cab)
}
}
}
}
</script>
</head>
<body onload="initMap()">
<h1>Cabspotting JS</h1>
<p><a href="javascript:map.zoomIn()">zoom in</a> | <a href="javascript:map.zoomOut()">zoom out</a>
<br><a href="javascript:map.panLeft()">pan left</a> | <a href="javascript:map.panRight()">pan right</a> | <a href="javascript:map.panDown()">pan down</a> | <a href="javascript:map.panUp()">pan up</a></p>
<div id="map">
</div>
</body>
</html>