-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmap.html
82 lines (64 loc) · 1.81 KB
/
gmap.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var myLatLng = {lat: parseFloat(localStorage.getItem('pos').split(",")[0]), lng:parseFloat(localStorage.getItem('pos').split(",")[1])};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.SATELLITE
});
/* var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});*/
window.map = map;
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDilvgs9eFQBu4CmwaYwhOX10cZKe1JbK4&callback=initMap">
</script>
</body>
</html>
<script type="text/javascript">
setInterval(updateMap,5000);
var lastPos;
function updateMap(event)
{
var newPos = localStorage.getItem('pos');
if(newPos===lastPos)
{
console.log("No change...");
}
else
{
lastPos = newPos;
var myLatLng = {lat: parseFloat( localStorage.getItem('pos').split(",")[0]), lng: parseFloat( localStorage.getItem('pos').split(",")[1])};
new google.maps.Marker({
position: myLatLng,
map: window.map,
title: 'Hello World!'
});
console.log("changed...");
}
}
// setTimeout(updateMap,3000);
</script>