forked from PokemonGoF/PokemonGo-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
77 lines (77 loc) · 2.35 KB
/
index.html
File metadata and controls
77 lines (77 loc) · 2.35 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body >
<div id="map"></div>
<script>
var map;
var marker;
var loc = {};
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 50.0830986, lng: 6.7613762},
zoom: 8
});
setTimeout(function(){
placeTrainer();
setTimeout(function(){
setInterval(updateTrainer, 1000);
}, 5000);
}, 5000);
}
function placeTrainer() {
loadJSON('location.json',
function(data) { loc = data; map.setZoom(16); map.panTo({lat: parseInt(loc.lat), lng: parseInt(loc.lng)}); },
function(xhr) { console.error(xhr);}
);
console.log("New Marker: Trainer - " + loc.lat + ", " + loc.lng);
marker = new google.maps.Marker({
map: map,
position: {lat: parseInt(loc.lat), lng: parseInt(loc.lng)},
icon: "image/trainer-icon.png"
});
}
function updateTrainer() {
loadJSON('location.json',
function(data) { loc = data; map.panTo({lat: parseInt(loc.lat), lng: parseInt(loc.lng)}); },
function(xhr) { console.error(xhr);}
);
console.log("Move Marker: Trainer - " + loc.lat + ", " + loc.lng);
marker.setPosition({lat: parseInt(loc.lat), lng: parseInt(loc.lng)});
}
function loadJSON(path, success, error) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
if (success)
success(JSON.parse(xhr.responseText));
} else {
if (error)
error(xhr);
}
}
};
xhr.open("GET", path, true);
xhr.send();
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBWa0ZYeH6RBZnNTAIj30FyDIVnXV74D9o&callback=initMap"
async defer></script>
</body>
</html>