-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
43 lines (43 loc) · 1.18 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
<!DOCTYPE html>
<html>
<head>
<title>Cordova Background Geolocation Tracking</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="//maps.googleapis.com/maps/api/js?key={{API KEY HERE}}"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var allMarkers = [];
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
var socket = io('http://localhost:3000');
socket.on('locations', function(locations){
locations = locations || [];
var markers = locations.map(function(location) {
var marker = new google.maps.Marker({
position: {lat: location.latitude, lng: location.longitude},
map: map
});
map.setCenter(marker.getPosition());
return marker;
});
allMarkers = allMarkers.concat(markers);
});
</script>
</body>
</html>