-
Notifications
You must be signed in to change notification settings - Fork 109
/
demo-no-simulation.html
43 lines (41 loc) · 1.41 KB
/
demo-no-simulation.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
<html>
<head>
<title>javascript-mobile-desktop-geolocation Demo With No Simulation</title>
<style>
.error { color: red;}
ul { display: none;}
</style>
</head>
<body>
<h1>javascript-mobile-desktop-geolocation With No Simulation</h1>
<h2>Results:</h2>
<p id="result">
<ul id="coordinates">
<li id="latitude"></li>
<li id="longitude"></li>
</ul>
</p>
<script src="js/geoPosition.js" type="text/javascript" charset="utf-8"></script>
<script src="js/geoPositionSimulator.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
if(geoPosition.init()){
geoPosition.getCurrentPosition(success_callback,error_callback,{enableHighAccuracy:true});
}
else{
document.getElementById('result').innerHTML = '<span class="error">Functionality not available</span>';
}
function success_callback(p)
{
var latitude = parseFloat( p.coords.latitude ).toFixed(2);
var longitude = parseFloat( p.coords.longitude ).toFixed(2);
document.getElementById('latitude').innerHTML = '<span class="information">Latitude:</span>' + latitude;
document.getElementById('longitude').innerHTML = '<span class="information">Longitude:</span>' + longitude;
document.getElementById('coordinates').style.display = 'block';
}
function error_callback(p)
{
document.getElementById('result').innerHTML = '<span class="error">' + p.message + '</span>';
}
</script>
</body>
</html>