/*Location functions here*/
var getUserLocation = function () {
console.log("getting location");
//check if the geolocation object is supported, if so get position
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(displayLocation);
} else {
document.getElementById("locationData").innerHTML = "Sorry - your browser doesn't support geolocation!";
}
};
var displayLocation = function (position) {
//build text string including co-ordinate data passed in parameter
var displayText = "User latitude is " + position.coords.latitude + " and longitude is " + position.coords.longitude;
//display the string for demonstration
document.getElementById("locationData").innerHTML = displayText;
};
/*var displayError = function (error) {
//get a reference to the HTML element for writing result
var locationElement = document.getElementById("locationData");
//find out which error we have, output message accordingly
switch (error.code) {
case error.PERMISSION_DENIED:
locationElement.innerHTML = "Permission was denied";
break;
case error.POSITION_UNAVAILABLE:
locationElement.innerHTML = "Location data not available";
break;
case error.TIMEOUT:
locationElement.innerHTML = "Location request timeout";
break;
case error.UNKNOWN_ERROR:
locationElement.innerHTML = "An unspecified error occurred";
break;
default:
locationElement.innerHTML = "Who knows what happened...";
break;
}
};*/
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.