-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
32 lines (26 loc) · 857 Bytes
/
main.js
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
function find(){
function success(position){
var status = document.querySelector('#status');
var lat = document.querySelector('latitude');
var lon = document.querySelector('longitude');
status.innerHTML = 'found you!';
lat.innerHTML = position.coords.latitude;
lon.innerHTML = position.coords.longitude;
}
function fail(error){
var status = document.querySelector('#status');
var msg = '';
if(typeof error == 'string')
msg = error;
else
msg = 'error code:'+error.code;
}
var option = {
'enableHighAccuracy':true,
'timeout':10000,
'maximumAge':0
};
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(success, fail, option);
}else fail('not found');
}