MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / trackLocation

Function trackLocation

assets/js/deviceInfo.js:31–41  ·  view source on GitHub ↗
({ onSuccess, onError = () => { } })

Source from the content-addressed store, hash-verified

29 * @return {number}
30 */
31const trackLocation = ({ onSuccess, onError = () => { } }) => {
32 if ('geolocation' in navigator === false) {
33 return onError(new Error('Geolocation is not supported by your browser.'));
34 }
35
36 return navigator.geolocation.watchPosition(onSuccess, onError, {
37 enableHighAccuracy: true,
38 timeout: 5000,
39 maximumAge: 0
40 });
41};
42
43/**
44 * Get position error message from the given error code.

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected