-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathgoogle.html
81 lines (66 loc) · 1.78 KB
/
google.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
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<script type="text/javascript" src="../eon-map.js"></script>
<style type="text/css">
body {
padding: 0px;
margin: 0px;
}
</style>
</head>
<body>
<div style="width: 100%; height:500px" id="map"></div>
<div id='map'></div>
<script>
function getNonZeroRandomNumber(){
var random = Math.floor(Math.random()*199) - 99;
if(random==0) return getNonZeroRandomNumber();
return random;
}
</script>
<script>
var pubnub = new PubNub({
publishKey: 'demo',
subscribeKey: 'demo'
});
var channel = 'pubnub-mapbox' + getNonZeroRandomNumber();
eon.map({
pubnub: pubnub,
id: 'map',
channels: [channel],
connect: connect,
options: {
center: new L.LatLng(37.370375, -97.75613851),
zoom: 5
},
provider: 'google',
googleKey: 'AIzaSyBYcy2l0Yf4lDADZ_U0zi6dy0M6pFZyPQA',
googleMutant: {
type: 'roadmap',
styles: [
{elementType: 'labels', stylers: [{visibility: 'off'}]},
{featureType: 'water', stylers: [{color: '#000000'}]}
]
}
});
function connect() {
var point = {
latlng: [37.370375, -97.756138]
};
setInterval(function(){
var new_point = JSON.parse(JSON.stringify(point));
new_point.latlng = [
new_point.latlng[0] + (getNonZeroRandomNumber() * 0.05),
new_point.latlng[1] + (getNonZeroRandomNumber() * 0.1)
];
pubnub.publish({
channel: channel,
message: [new_point]
});
}, 1000);
};
</script>
</body>
</html>