Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. (function() {
  2.  
  3. if (navigator.geolocation) {
  4. function PositionError(code, message) {
  5. this.code = code;
  6. this.message = message;
  7. }
  8.  
  9. PositionError.PERMISSION_DENIED = 1;
  10. PositionError.POSITION_UNAVAILABLE = 2;
  11. PositionError.TIMEOUT = 3;
  12. PositionError.prototype = new Error();
  13.  
  14. navigator.geolocation._getCurrentPosition = navigator.geolocation.getCurrentPosition;
  15.  
  16. navigator.geolocation.getCurrentPosition = function(success, failure, options) {
  17. var successHandler = function(position) {
  18. if ((position.coords.latitude == 0 && position.coords.longitude == 0) ||
  19. (position.coords.latitude == 37.38600158691406 && position.coords.longitude == -122.08200073242188))
  20. return failureHandler(new PositionError(PositionError.POSITION_UNAVAILABLE, 'Position unavailable'));
  21.  
  22. failureHandler = function() {};
  23. success(position);
  24. }
  25.  
  26. var failureHandler = function(error) {
  27. failureHandler = function() {};
  28. failure(error);
  29. }
  30.  
  31. navigator.geolocation._getCurrentPosition(successHandler, failureHandler, options);
  32.  
  33. window.setTimeout(function() { failureHandler(new PositionError(PositionError.TIMEOUT, 'Timed out')) }, 10000);
  34. }
  35. }
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement