blob: ab1f8372556bd6e73e21360ad2af29e7bfd7a30a (
plain)
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
|
var geo = (function(){
var geo = {}
geo.fetch = function(){
navigator.geolocation.getCurrentPosition(geo.success, geo.error, {timeout: 15000})
}
geo.success = function(position){
var lat_str = as_degrees( position.coords.latitude )
var lng_str = as_degrees( position.coords.longitude )
$(".latlng").html( lat_str + " " + lng_str )
}
geo.error = function(error){
$(".latlng").html( "+40° 58' 90\" -74° 04' 46\"" )
}
function as_degrees (n) {
var s = ""
if (n >= 0) s += "+"
s += Math.floor(n) + "° "
n %= 1
n *= 60
s += Math.floor(n) + "'"
n %= 1
n *= 60
s += Math.floor(n) + '"'
}
return geo
})()
|