-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
156 lines (118 loc) · 3.86 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Metropia Data Visualisation</title>
<style>
.container {
margin: 0 auto;
width: 100%;
max-width: 1024px;
}
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.location, .location svg {
position: absolute;
}
.location svg {
width: 60px;
height: 20px;
padding-right: 100px;
font: 10px sans-serif;
}
.location circle {
fill: limegreen;
stroke-width: 1px;
}
.red, .red circle {
fill: red;
}
.orange, .orange circle {
fill: #daff00;
}
</style>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<!--JS-->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
// Create the Google Map…
var map = new google.maps.Map(d3.select("#map").node(), {
zoom: 10,
maxZoom: 12,
minZoom: 8,
center: new google.maps.LatLng(32.2214896,-110.9248817),
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
// Load the station data. When the data comes back, create an overlay.
d3.json("https://raw.githubusercontent.com/nayanseth/Visualisation/master/metropia.json", function(data) {
var overlay = new google.maps.OverlayView();
// Add the container when the overlay is added to the map.
overlay.onAdd = function() {
var layer = d3.select(this.getPanes().overlayLayer).append("div")
.attr("class", "location");
// Draw each marker as a separate SVG element.
// We could use a single SVG, but what size would it have?
overlay.draw = function() {
var projection = this.getProjection(),
padding = 10;
var marker = layer.selectAll("svg")
.data(d3.entries(data))
.each(transform) // update existing markers
.enter().append("svg:svg")
.each(transform)
.attr("class", "marker");
// Add a circle.
marker.append("svg:circle")
.attr("r", 1.5)
.attr("cx", padding)
.attr("cy", padding);
function transform(d) {
var speed=d.value.spd;
d = new google.maps.LatLng(d.value.lat, d.value.lon);
if(speed<20) {
d = projection.fromLatLngToDivPixel(d);
return d3.select(this)
.style("left", (d.x - padding) + "px")
.style("top", (d.y - padding) + "px")
.attr("class", "red");
}
else if (speed>20 && speed<=35) {
d = projection.fromLatLngToDivPixel(d);
return d3.select(this)
.style("left", (d.x - padding) + "px")
.style("top", (d.y - padding) + "px")
.attr("class", "orange");
}
else {
d = projection.fromLatLngToDivPixel(d);
return d3.select(this)
.style("left", (d.x - padding) + "px")
.style("top", (d.y - padding) + "px");
}
}
};
};
// Bind our overlay to the map…
overlay.setMap(map);
});
</script>
<!--
<div id="analyticsWindow" class="container">
</div>
-->
<!--JS
<script src="script.js" charset="utf-8"></script>
-->
<!--JS-->
<script src = "http://code.jquery.com/jquery-2.2.0.min.js"></script>
</body>
</html>