Created
March 27, 2018 16:31
-
-
Save evilnapsis/66f9236977fec489c76fd686e3ae0640 to your computer and use it in GitHub Desktop.
Obtener ubicacion y mostrarla en un mapa
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
<!-- Powered by Evilnapsis at http://evilnapsis.com/ --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Obtener ubicacion</title> | |
</head> | |
<body> | |
<h1>Obtener ubicacion y mostrarla en un mapa</h1> | |
<div id="map" style="width:100%;height:600px;"></div> | |
<script> | |
navigator.geolocation.getCurrentPosition(function(location) { | |
console.log(location.coords.latitude); | |
console.log(location.coords.longitude); | |
var map; | |
var center = {lat: location.coords.latitude, lng: location.coords.longitude}; | |
function initMap() { | |
map = new google.maps.Map(document.getElementById('map'), { | |
center: center, | |
zoom: 6 | |
}); | |
var marker = new google.maps.Marker({ | |
position: {lat: location.coords.latitude, lng: location.coords.longitude}, | |
map:map, | |
title: 'Ubication' | |
}); | |
} | |
initMap(); | |
}); | |
</script> | |
<script async defer | |
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDuBEidKGDuQo7Bzf1uRg47MPaRRlEesw0"> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment