1var options = {
2 enableHighAccuracy: true,
3 timeout: 5000,
4 maximumAge: 0
5};
6
7function success(pos) {
8 var crd = pos.coords;
9
10 console.log('Your current position is:');
11 console.log(`Latitude : ${crd.latitude}`);
12 console.log(`Longitude: ${crd.longitude}`);
13 console.log(`More or less ${crd.accuracy} meters.`);
14}
15
16function error(err) {
17 console.warn(`ERROR(${err.code}): ${err.message}`);
18}
19
20navigator.geolocation.getCurrentPosition(success, error, options);
21