code
2

Mock geolocation

Useful if you’re working on a website meant for mobile devices. Firefox 3.5 has geolocation, but I use this with Safari and GreaseKit. Replace with whatever latitude and longitude you prefer, naturally.

if (!('geolocation' in navigator)) {
  navigator.geolocation = {
    watchPosition: function(success, f, options) {
      var broadcast = function() {
        var position = {
          coords: {
            latitude: 30.2696384,
            longitude: -97.74947,
            accuracy: 10000,
          },
          timestamp: (new Date()).valueOf()
        };        
        success(position);
      };
      
      broadcast();
      window.setInterval(broadcast, 10000);
    }
  };
}

Comments