forked from TBTerra/spawnScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewWork.html
74 lines (70 loc) · 1.57 KB
/
viewWork.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
<!DOCTYPE html>
<html>
<head>
<style>
#map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
position: absolute;
left: 0px;
top: 0px;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="legend"><h3>Legend</h3></div>
<script>
function getFile(path, asynch, callback) {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json");
xhr.open("GET", path, asynch);
xhr.onload = function (e) {
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.onerror = function (e) {
console.error(xhr.status);
};
xhr.send(null);
}
var works = [];
function initMap() {
var mapDiv = document.getElementById('map');
var map = new google.maps.Map(mapDiv, {
center: {lat: 52.17, lng: -1.4408},
zoom: 8,
});
getFile('./config.json', true, function(response) {
console.log('got work');
var data = JSON.parse(response);
var D = data.work;
for (var i = 0; i < D.length; i++) {
var p = D[i];
var rectangle = new google.maps.Rectangle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
bounds: {
north: p[0],
south: p[2],
east: p[3],
west: p[1]
}
});
works.push(rectangle);
}
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
</body>
</html>