-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (90 loc) · 2.72 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Pizza Tracker</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
<script type="text/javascript" src="https://rawgit.com/deepstreamIO/deepstream.io-client-js/master/dist/deepstream.min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
var map;
var client;
var markers={};
var pizzaIcon = 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/PEO-pizza.svg/32px-PEO-pizza.svg.png';
function addDeliveryTracking( trackingId ) {
var record = client.record.getRecord( trackingId );
var marker = new google.maps.Marker({
map: map,
title: `Location of delivery person: ${trackingId}`,
icon: pizzaIcon
});
record.subscribe( function( data ) {
if( data.lon ) {
data.lng = data.lon;
}
marker.setPosition(data);
} );
markers[ trackingId ] = marker;
}
function removeDeliveryTracking( trackingId ) {
markers[ trackingId ].setMap( null );
delete markers[ trackingId ];
}
function renderList( list ) {
list.getEntries().forEach( addDeliveryTracking );
list.on( 'entry-added', addDeliveryTracking );
list.on( 'entry-removed', removeDeliveryTracking );
}
function initDeepstreamClient() {
client = deepstream( '52.29.229.244:6020' );
client.login( {}, function( success ) {
var list = client.record.getList( 'pizza-tracker/users' );
list.whenReady( renderList );
});
}
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: {lat: 52.52220663, lng: 13.40849051},
styles: [
{
featureType: 'all',
stylers: [
{ saturation: -80 }
]
},{
featureType: 'road.arterial',
elementType: 'geometry',
stylers: [
{ hue: '#00ffee' },
{ saturation: 50 }
]
},{
featureType: 'poi.business',
elementType: 'labels',
stylers: [
{ visibility: 'off' }
]
}
]
});
initDeepstreamClient();
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBm8FqDM3TZ6k2zRxwVhvFA2DVaBwq6qps&callback=initMap">
</script>
</body>
</html>