-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (52 loc) · 1.25 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>Geolocation</title>
<link rel="stylesheet" href="">
</head>
<body>
<header>
<h1>Geolocation</h1>
</header>
<div id="Output"></div>
<script>
navigator.geolocation.watchPosition(
gotPosition,
errorGettingPosition,
{'enableHighAccuracy':true,'timeout':10000,'maximumAge':20000});
function gotPosition(pos)
{
var outputStr =
"latitude:"+ pos.coords.latitude +"<br>"+
"longitude:"+ pos.coords.longitude +"<br>"+
"accuracy:"+ pos.coords.accuracy +"<br>"+
"altitude:"+ pos.coords.altitude +"<br>"+
"altitudeAccuracy:"+ pos.coords.altitudeAccuracy +"<br>"+
"heading:"+ pos.coords.heading +"<br>"+
"speed:"+ pos.coords.speed +"";
document.getElementById("Output").innerHTML=outputStr;
}
function errorGettingPosition(err)
{
if(err.code==1)
{
alert("User denied geolocation.");
}
else if(err.code==2)
{
alert("Position unavailable.");
}
else if(err.code==3)
{
alert("Timeout expired.");
}
else
{
alert("ERROR:"+ err.message);
}
}
</script>
</body>
</html>