samedi 31 janvier 2015

How do I get my HTML5 Location result in a global variable?



function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geen geolocatie hier.";
}

function showPosition(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var total = String(lat).concat(',', String(lon));
}


How do I get that last 'total'-variable to be usable in other functions? And why doesn't declaring a global variable in the showPosition() function seem to work?





Aucun commentaire:

Enregistrer un commentaire