Skip to content

Instantly share code, notes, and snippets.

@karlazz
Created April 25, 2019 21:45
Show Gist options
  • Save karlazz/21a3e804637bedfe209683e34b601df3 to your computer and use it in GitHub Desktop.
Save karlazz/21a3e804637bedfe209683e34b601df3 to your computer and use it in GitHub Desktop.
function showLocation(position) {
window.location.href ="http://YOURDOMAINHERE/events/map/?action=tribe_list&tribe_paged=1&tribe-bar-geoloc-lat="+ position.coords.latitude +"&tribe-bar-geoloc-lng="+ position.coords.longitude;
}
function errorHandler(err) {
if(err.code == 1) {
alert("Error: Access is denied!");
}else if( err.code == 2) {
alert("Error: Position is unavailable!");
}
}
function getLocation(){
if(navigator.geolocation){
// timeout at 60000 milliseconds (60 seconds)
var options = {timeout:60000};
navigator.geolocation.getCurrentPosition(showLocation,
errorHandler,
options);
}else{
alert("Sorry, browser does not support geolocation!");
}
}
getLocation();
//https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/13195095-option-to-automatically-list-events-near-to-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment