Created
February 16, 2013 16:06
-
-
Save emedinaa/4967473 to your computer and use it in GitHub Desktop.
Html5 Geolocation - GDG Girls - Ejemplo 1
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<p id="geo">Click para saber tus coordenadas</p> | |
<button onClick="getLocation()"> Aqui</button> | |
<script type="text/javascript"> | |
var geo=document.getElementById("geo"); | |
function getLocation() | |
{ | |
//navigator esta permitido la geolocalización | |
if(navigator.geolocation) | |
{ | |
//genial se donde estas | |
console.log("genial se donde estas"); | |
navigator.geolocation.getCurrentPosition(showPosition); | |
}else | |
{ | |
//on tas? console.log("on ta BB"); | |
geo.innerHTML="No esta soportado en este dispositivo/browser"; | |
} | |
} | |
function showPosition(position) | |
{ | |
//console.log("latitude "+position.coords.latitude); | |
//console.log("longitude "+position.coords.longitude); | |
geo.innerHTML="Latitude "+position.coords.latitude+ | |
"<br> Longitude "+position.coords.longitude; | |
//latitud | |
//position.coords.longitude;//longitud | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment