Skip to content

Instantly share code, notes, and snippets.

@Artistan
Created March 23, 2016 09:04
Show Gist options
  • Save Artistan/c33d8b29172c38cded70 to your computer and use it in GitHub Desktop.
Save Artistan/c33d8b29172c38cded70 to your computer and use it in GitHub Desktop.
var location_timeout = setTimeout(function () {
navigator.geolocation.clearWatch(WatchID);
self.findLocationByIP(callback);
}, 15000);
var WatchID = navigator.geolocation.watchPosition(
function (position) { // Success callback
clearTimeout(location_timeout);
self.setFoundUserLocation(position.coords.latitude, position.coords.longitude, callback);
},
function () { // Error callback
clearTimeout(location_timeout);
self.findLocationByIP(callback);
},
{maximumAge: 100000, timeout: 12000, enableHighAccuracy: true} // Options
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment