-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
77 lines (74 loc) · 3.63 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
<style type="text/css">
html, body, #map-canvas { height: 100%; margin: 0; padding: 0;}
</style>
<title>Where's my music at?</title>
</head>
<body>
<div class="container-fluid" style="height:90%;margin-top:50px;">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="img/logo_tm_black.jpg" style="height:25px;margin-top:-3px;" alt="Soundwave">
</a>
</div>
<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
</div><!-- /.container-fluid -->
</nav>
<div class="row" style="height:100%">
<div class="col-md-12" style="height:100%">
<div id="map-canvas" style="height:100%"></div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize(cb) {
var mapOptions = {
center: { lat: 0, lng: 0},
zoom: 2
};
window.map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
cb();
};
window.artistFilter = "";
window.onload = function(){
//document.getElementById('artistFilterSearchString').addEventListener('keyup',function(e){
// window.artistFilter = e.target.value;
//});
setTimeout(function(){
initialize(function(){
window.ws = new WebSocket('ws://soundwaveapi.herokuapp.com/scrobble-firehose');
window.ws.onmessage = function(message){
var data = JSON.parse(message.data);
if(data.action.location){
var marker = new google.maps.Marker({
position: {
lat:data.action.location.lat,
lng:data.action.location.lon
},
title:data.action.song.artist+" - "+data.action.song.title
});
var contentString = '<div class="media" style="max-width:250px;">'+(data.action.song.imageURL_200?'<div class="media-left"><img class="media-object" style="max-width:50px;" src="'+data.action.song.imageURL_200+'" alt=""></div>':'')+'<div class="media-body"><h4 class="media-heading">'+data.action.song.artist+'</h4><h6>'+data.action.song.title+'</h6></div></div>';
var infowindow = new google.maps.InfoWindow({
content:contentString
});
infowindow.open(window.map,marker);
// To add the marker to the map, call setMap();
marker.setMap(window.map);
setTimeout(function(){marker.setMap(null);infowindow.close();},3000);
}
}
});
},500);
};
</script>
</html>