-
Notifications
You must be signed in to change notification settings - Fork 0
/
reports.js
88 lines (70 loc) · 2.1 KB
/
reports.js
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
83
84
85
86
87
88
var map;
var marker;
var infowindow;
var messagewindow;
var report;
var location;
function initMap() {
var home = {lat: -34.397, lng: 150.644};
map = new google.maps.Map(document.getElementById('map'), {
center: home,
zoom: 2
});
marker = new google.maps.Marker({ //creating permanent marker on map (Santa Paula)
position: {lat: 34.3542, lng: -119.0503},
map: map
});
marker = new google.maps.Marker({ //creating permanent marker on map (Santa Paula)
position: {lat: -23.6980, lng: 133.8807},
map: map
});
infowindow = new google.maps.InfoWindow({
content: document.getElementById('form')
});
messagewindow = new google.maps.InfoWindow({
content: document.getElementById('message')
});
google.maps.event.addListener(map, 'click', function(event) {
marker = new google.maps.Marker({
position: event.latLng,
map: map
});
location = {lat: event.latLng.lat(), lng: event.latLng.lng()};
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
form.hidden = false;
});
});
marker = new google.maps.Marker({
position: location,
map:map
});
}
function saveData() {
var location = escape(document.getElementById('Location').value);
var type = document.getElementById('type').value;
var latlng = marker.getPosition();
var url = 'phpsqlinfo_addrow.php?Location=' + location +
'&lat=' + latlng.lat() + '&lng=' + latlng.lng() + '&type=' + type;
downloadUrl(url, function(data, responseCode) {
if (responseCode == 200 && data.length <= 1) {
infowindow.close();
messagewindow.open(map, marker);
}
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request.responseText, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing () {
}