/
gps.html
52 lines (43 loc) · 1.41 KB
/
gps.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
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://www.google.com/jsapi?key=ABQIAAAAuzAIVuxQQsE9dd3bqoaXYRQUz4ZbQexkw63CeNjSF7UDjimi6RSkE5kxeAdhaJdWpHNs1hWLtAofUg" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<![CDATA[
google.load("jquery", "1.4.2");
//]]>
</script>
<script type="text/javascript">
function getGPS() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(postGPS, gpsError);
} else {
gpsText.innerText = "No GPS Functionality.";
}
}
function gpsError(error) {
alert("GPS Error: "+error.code+", "+error.message);
}
function showGPS(position) {
form = document.updateLocation;
form.longitude.value = position.coords.longitude;
form.latitude.value = position.coords.latitude;
}
function postGPS(position) {
form = document.updateLocation;
form.longitude.value = position.coords.longitude;
form.latitude.value = position.coords.latitude;
form.submit();
}
function initialize() {
var getLocationInterval = setInterval(getGPS, 30000);
navigator.geolocation.getCurrentPosition(showGPS, gpsError);
}
</script>
</head>
<body onload="initialize();" >
<form action="/123/gps/" method="post" name="updateLocation">
Longitude: <input type=text name="longitude"><br>
Latitude: <input type=text name="latitude"><br><input type="submit"></form>
</body>
</html>