open-austin / recycling-atx

:recycle::recycle::recycle:
http://open-austin.github.io/recycling-atx/
9 stars 5 forks source link

Fixes #29: UI stuck in "loading" if user rejects "share location" prompt #33

Open twomice opened 8 years ago

prestonp commented 8 years ago

Hey so this doesn't address the case where a browser does support geolocation but clicks deny.

We could add an error handler for that case. Here's a snippet from https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;

  console.log('Your current position is:');
  console.log('Latitude : ' + crd.latitude);
  console.log('Longitude: ' + crd.longitude);
  console.log('More or less ' + crd.accuracy + ' meters.');
};

function error(err) {
  console.warn('ERROR(' + err.code + '): ' + err.message);
};

navigator.geolocation.getCurrentPosition(success, error, options);

So in the project, success and error handler should turn off the spinner. If the user doesn't have geolocation, it should not turn the spinner on.