forked from tyler124/Monitordroid-Web-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation.php
177 lines (112 loc) · 4.23 KB
/
location.php
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<title>Location</title>
<style type="text/css">
html, body {height: 100%}
html { overflow: hidden;
}
body { margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
</style>
<?php
// receive data from HTML readsms request
$rName=$_POST["registration"];
$rowId=$_POST["rowid"];
$dName=$_POST["devicename"];
include_once './db_functions.php';
$db = new DB_Functions();
$lat = $db->getLat($rName);
$long = $db->getLong($rName);
?>
<style>
#map_canvas {
width: 100%;
height: 89%;
}
ul.devices li .send_btn{
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0096FF), to(#005DFF));
background: -webkit-linear-gradient(0% 0%, 0% 100%, from(#0096FF), to(#005DFF));
background: -moz-linear-gradient(center top, #0096FF, #005DFF);
background: linear-gradient(#0096FF, #005DFF);
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
border-radius: 3px;
color: #fff;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
if (window.attachEvent) {
window.attachEvent("onresize", function( ) {this.map.onResize( )} );
window.attachEvent("onload", function( ) {this.map.onResize( )} );
}
else if (window.addEventListener) {
window.addEventListener("resize", function( ) {this.map.onResize( )} , false);
window.addEventListener("load", function( ) {this.map.onResize( )} , false);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
geocoder = new google.maps.Geocoder();
var map_canvas = document.getElementById('map_canvas');
var latlng = new google.maps.LatLng(<?php echo $lat ?>,<?php echo $long ?>);
var map_options = {
center: latlng,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, map_options)
geocoder.geocode({'latLng': latlng}, function(results, status) { //doesn't work
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
infowindow.setContent(results[1].formatted_address);
}
}
});
var marker = new google.maps.Marker({
position: latlng,
title:"<?php echo $dName ?>"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker); //doesn't work
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
});
function sendPushNotification(id){
var data = $('form#'+id).serialize();
$('form#'+id).unbind('submit');
$.ajax({
url: "send_message.php",
type: 'GET',
data: data,
beforeSend: function() {
},
success: function(data, textStatus, xhr) {
$('.txt_message').val("");
},
error: function(xhr, textStatus, errorThrown) {
}
});
return false;
}
</script>
</head>
<body>
<a href="javascript:history.back()">Home</a>
<p>Instructions: Click "Update Location" and then refresh the page for the current location of the device.</p>
<form id="<?php echo $rowId ?>" name="" method="post" onsubmit="return sendPushNotification('<?php echo $rowId ?>')">
<input type="hidden" name="message" value="location" />
<input type="hidden" name="regId" value="<?php echo $rName ?>"/>
<input type="submit" class="send_btn" value="Update Location" onclick=""/>
</form>
<div id="map_canvas"></div>
</body>
</html>