1 module uim.html.geolocation;
2 
3 import uim.html;
4 
5 
6 /*
7 <script>
8 var x = document.getElementById("demo");
9 function getLocation() {
10   if (navigator.geolocation) {
11      navigator.geolocation.getCurrentPosition(showPosition);
12   } else {
13      x.innerHTML = "Geolocation is not supported by this browser.";
14    }
15 }
16 
17  function showPosition(position) {
18   x.innerHTML = "Latitude: " + position.coords.latitude + 
19   "<br>Longitude: " + position.coords.longitude; 
20  }
21 </script>
22 */
23 
24 /*
25 function showError(error) {
26   switch(error.code) {
27     case error.PERMISSION_DENIED:
28        x.innerHTML = "User denied the request for Geolocation."
29        break;
30     case error.POSITION_UNAVAILABLE:
31        x.innerHTML = "Location information is unavailable."
32       break;
33     case error.TIMEOUT:
34        x.innerHTML = "The request to get user location timed out."
35        break;
36     case error.UNKNOWN_ERROR:
37       x.innerHTML = "An unknown error occurred."
38       break;
39    }
40  } 
41  */
42 
43  /* function showPosition(position) {
44   var latlon = position.coords.latitude + "," + position.coords.longitude;
45 
46   var img_url = "https://maps.googleapis.com/maps/api/staticmap?center=
47    "+latlon+"&zoom=14&size=400x300&sensor=false&key=YOUR_KEY";
48 
49    document.getElementById("mapholder").innerHTML = "<img src='"+img_url+"'>";
50  }
51  */
52 
53  /*
54  The getCurrentPosition() method returns an object on success. The latitude, longitude and accuracy properties are always returned. The other properties are returned if available:
55 
56 
57 Property
58 
59 Returns
60 
61 coords.latitude The latitude as a decimal number (always returned) 
62 coords.longitude The longitude as a decimal number (always returned) 
63 coords.accuracy The accuracy of position (always returned) 
64 coords.altitude The altitude in meters above the mean sea level (returned if available) 
65 coords.altitudeAccuracy The altitude accuracy of position (returned if available) 
66 coords.heading The heading as degrees clockwise from North (returned if available) 
67 coords.speed The speed in meters per second (returned if available) 
68 timestamp The date/time of the response (returned if available) 
69 */
70 
71 /*
72 The Geolocation object also has other interesting methods:
73 •watchPosition() - Returns the current position of the user and continues to return updated position as the user moves (like the GPS in a car).
74 •clearWatch() - Stops the watchPosition() method.
75 
76 The example below shows the watchPosition() method. You need an accurate GPS device to test this (like smartphone): 
77 
78 <script>
79 var x = document.getElementById("demo");
80 function getLocation() {
81    if (navigator.geolocation) {
82     navigator.geolocation.watchPosition(showPosition);
83   } else {
84      x.innerHTML = "Geolocation is not supported by this browser.";
85    }
86 }
87  function showPosition(position) {
88   x.innerHTML = "Latitude: " + position.coords.latitude + 
89   "<br>Longitude: " + position.coords.longitude; 
90  }
91 </script>
92 */