-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatchme.html
62 lines (51 loc) · 2.03 KB
/
watchme.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
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="socket.io.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var map;
var infowindow = new google.maps.InfoWindow();
var geocoder = new google.maps.Geocoder();
var initialLocation;
var watchId;
window.addEventListener('load', initialise, false);
function initialise() {
var mapOptions = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var socket = new io.Socket();
socket.connect();
socket.addEvent('message', function(data) {
/*var output = '';
for (property in data) {
output += property + ': ' + data[property]+'; ';
}
console.log(output);*/
//console.log(data);
reverse_geocode(data);
});
}
function reverse_geocode(position) {
initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
geocoder.geocode({'latLng' : initialLocation}, draw_map);
}
function draw_map(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
infowindow.setContent(results[1].formatted_address);
}
}
map.setCenter(initialLocation);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}
</script>
</head>
<body>
<div id="map_canvas" style="position: absolute; background-color: rgb(229, 227, 223); overflow-x: hidden; overflow-y: hidden; z-index: 0; height: 100%; width: 100%;"></div>
</body>
</html>