-
Notifications
You must be signed in to change notification settings - Fork 0
/
DispLatLong.php
65 lines (53 loc) · 1.54 KB
/
DispLatLong.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
<html>
<head>
<?php include 'Header.php'; ?>
<script>
var startPos;
var map;
function init()
{
if(navigator.geolocation)
{
document.getElementById("support").innerHTML = "<p style='color:green'>Great! This browser supports HTML5 Geolocation</p>";
navigator.geolocation.getCurrentPosition(updateLocation,handleLocationError,{timeout:50000});
//navigator.geolocation.watchPosition(updateCurrPosition,handleLocationError);
}
else
{
document.getElementById("support").innerHTML = "<p style='color:red'>Oops! This browser does not support HTML5 Geolocation</p>";
}
}
function updateLocation(position)
{
startPos = position;
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("lat").innerHTML = latitude;
document.getElementById("lng").innerHTML = longitude;
}
function handleLocationError(error)
{
switch(error.code)
{
case 0:
updateStatus("There was an error while retrieving your location: " + error.message);
break;
case 1:
updateStatus("The user prevented this page from retrieving the location.");
break;
case 2:
updateStatus("The browser was unable to determine your location: " + error.message);
break;
case 3:
updateStatus("The browser timed out before retrieving the location.");
break;
}
}
</script>
</head>
<body onload="init()">
<div id="support"></div>
Latitude <div id="lat"></div>
Longitude <div id="lng"></div>
</body>
</html>