-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
61 lines (56 loc) · 1.91 KB
/
map.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
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html, body, #map-canvas { height: 100%; margin: 0; padding: 0;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
var data;
var map;
var max = 10;
function initialize() {
var mapOptions = {
center: { lat: 41.8369, lng: -87.6847},
zoom: 8
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
google.maps.Map.prototype.markers = new Array();
google.maps.Map.prototype.clearMarkers = function() {
for(var i=0; i<this.markers.length; i++){
this.markers[i].setMap(null);
}
this.markers = new Array();
};
$.get("/ranks.csv")
.done(function(csvdata) {
data = $.csv.toArrays(csvdata);
refreshMarkers();
})
.fail(function() {
console.log("Error");
document.body.innerHTML = "<h1>Error getting or parsing data</h1>"
});
}
function refreshMarkers() {
for(var i = 0; i < data.length && i < max; i++) {
var datum = data[i];
var marker = new google.maps.Marker({
position: {lat: parseFloat(datum[1]), lng: parseFloat(datum[2])},
map: map,
title: datum[0],
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' + i + '|FF0000|000000',
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>