-
Notifications
You must be signed in to change notification settings - Fork 1
/
location.js
55 lines (47 loc) · 1.43 KB
/
location.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function getLocation(){
console.log("you called get location");
var startPos;
var geoOptions = {
timeout: 10 * 1000,
maximumAge: 1 * 60 * 1000
}
var geoSuccess = function(position) {
// Do magic with location
startPos = position;
document.getElementById('lat').value = startPos.coords.latitude;
document.getElementById('long').value = startPos.coords.longitude;
// document.getElementById("location").value="location captured";
};
var geoError = function(error) {
switch(error.code) {
case error.TIMEOUT:
// The user didn't accept the callout
console.log("there is some problem to capture location");
break;
}
};
navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions)
}
function SgetLocation(){
console.log("you called get slocation");
var startPos;
var geoOptions = {
timeout: 10 * 1000,
maximumAge: 1 * 60 * 1000
}
var geoSuccess = function(position) {
// Do magic with location
startPos = position;
document.getElementById('Slat').value = startPos.coords.latitude;
document.getElementById('Slong').value = startPos.coords.longitude;
};
var geoError = function(error) {
switch(error.code) {
case error.TIMEOUT:
// The user didn't accept the callout
console.log("there is some problem to capture location");
break;
}
};
navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions)
}