Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Locator(successCallback, errorCallback)
- {
- this.success = (location) =>
- {
- console.dir(location);
- this.pauseLocationUpdates();
- successCallback(location);
- };
- this.error = () =>
- {
- console.log("Failed to access location");
- errorCallback();
- };
- this.pauseLocationUpdates = () =>
- {
- if(this.watchID !== null)
- {
- navigator.geolocation.clearWatch(this.watchID);
- this.watchID = null;
- }
- };
- this.options = {
- enableHighAccuracy: true,
- maximumAge : 30000,
- timeout : 27000
- };
- this.locate = () =>
- {
- var browserSupportsLocation = "geolocation" in navigator;
- if (browserSupportsLocation)
- {
- this.watchID = navigator.geolocation.watchPosition(this.success, this.error, this.options);
- }
- else
- {
- this.error();
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement