dist/evrythng.js
function(options){
      if (typeof window !== 'undefined' && window.navigator.geolocation) {

        // Have default options, but allow to extend with custom.
        var geolocationOptions = this.extend({
          maximumAge: 0,
          timeout: 10000,
          enableHighAccuracy: true
        }, options);

        return new Promise(function (resolve, reject) {

          window.navigator.geolocation.getCurrentPosition(function (position) {

            resolve(position);

          }, function (err) {

            var errorMessage = 'Geolocation: ';
            if(err.code === 1) {
              errorMessage = 'You didn\'t share your location.';
            } else if(err.code === 2) {
              errorMessage = 'Couldn\'t detect your current location.';
            } else if(err.code === 3) {
              errorMessage = 'Retrieving position timed out.';
            } else {
              errorMessage = 'Unknown error.';
            }
            reject(errorMessage);

          }, geolocationOptions);

        });

      }else{
        return new Promise(function (resolve, reject) {
          reject('Your browser\/environment doesn\'t support geolocation.');
        });
      }
    }
function(options){
      if (typeof window !== 'undefined' && window.navigator.geolocation) {

        // Have default options, but allow to extend with custom.
        var geolocationOptions = this.extend({
          maximumAge: 0,
          timeout: 10000,
          enableHighAccuracy: true
        }, options);

        return new Promise(function (resolve, reject) {

          window.navigator.geolocation.getCurrentPosition(function (position) {

            resolve(position);

          }, function (err) {

            var errorMessage = 'Geolocation: ';
            if(err.code === 1) {
              errorMessage = 'You didn\'t share your location.';
            } else if(err.code === 2) {
              errorMessage = 'Couldn\'t detect your current location.';
            } else if(err.code === 3) {
              errorMessage = 'Retrieving position timed out.';
            } else {
              errorMessage = 'Unknown error.';
            }
            reject(errorMessage);

          }, geolocationOptions);

        });

      }else{
        return new Promise(function (resolve, reject) {
          reject('Your browser\/environment doesn\'t support geolocation.');
        });
      }
    }
function ( options ) { if ( typeof window !== 'undefined' && window . navigator . geolocation ) { // Have default options, but allow to extend with custom. var geolocationOptions = this . extend ( { maximumAge : 0 , timeout : 10000 , enableHighAccuracy : true } , options ) ; return new Promise ( function ( resolve , reject ) { window . navigator . geolocation . getCurrentPosition ( function ( position ) { resolve ( position ) ; } , function ( err ) { var errorMessage = 'Geolocation: ' ; if ( err . code === 1 ) { errorMessage = 'You didn\'t share your location.' ; } else if ( err . code === 2 ) { errorMessage = 'Couldn\'t detect your current location.' ; } else if ( err . code === 3 ) { errorMessage = 'Retrieving position timed out.' ; } else { errorMessage = 'Unknown error.' ; } reject ( errorMessage ) ; } , geolocationOptions ) ; } ) ; } else { return new Promise ( function ( resolve , reject ) { reject ( 'Your browser\/environment doesn\'t support geolocation.' ) ; } ) ; } }
Get current position using HTML5 Geolocation and resolve promise once it has returned.
Get current position using HTML5 Geolocation and resolve promise once it has returned .