Skip to content

Instantly share code, notes, and snippets.

@KoryNunn
Created January 14, 2013 16:21
Show Gist options
  • Select an option

  • Save KoryNunn/4531223 to your computer and use it in GitHub Desktop.

Select an option

Save KoryNunn/4531223 to your computer and use it in GitHub Desktop.
Gets the users position, caching requests between position checks. Solves huge lag issue in chrome for android.
var requestCallbacks = [],
ready = true;
function getPosition(callback){
requestCallbacks.push(callback);
if(ready){
ready = false;
navigator.geolocation.getCurrentPosition(function(position){
while(requestCallbacks.length){
requestCallbacks.pop()(position);
}
ready = true;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment