Created
May 3, 2012 06:12
-
-
Save max-power/2583676 to your computer and use it in GitHub Desktop.
HTML5 Geolocation Polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires jquery.js, tested with reqwest.js with jquery compat mode | |
// uses http://geoplugin.net/json.gp | |
// lowercase arguments are just string placeholder | |
// F = Function placeholder | |
// Z = Cache placeholder | |
;(function(N,g,c,x,y,u,j,F,Z) { | |
F=function(s,e){Z?s(Z):$.ajax({url:'//'+u+'.net/'+j+'.gp',dataType:j+'p',jsonp:j+'callback',error:e,success:function(R){Z={};Z[c]={};Z[c][x]=R[u+'_'+x];Z[c][y]=R[u+'_'+y];s(Z)}})} | |
N[g]=N[g]||{getCurrentPosition:F,watchPosition:F,clearWatch:function(){Z=undefined}} | |
})(navigator,'geolocation','coords','latitude','longitude','geoplugin','json'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment