Created
November 27, 2018 10:16
-
-
Save RomainMaillot13/6fb058bbba66b8cc60d0b6178db63346 to your computer and use it in GitHub Desktop.
connect to google map api
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
function maPosition(position) { | |
var infopos = "Position déterminée :\n"; | |
infopos += "Latitude : "+position.coords.latitude +"\n"; | |
infopos += "Longitude: "+position.coords.longitude+"\n"; | |
infopos += "Altitude : "+position.coords.altitude +"\n"; | |
infopos += "Vitesse : "+position.coords.speed +"\n"; | |
document.getElementById("infoposition").innerHTML = infopos; | |
// Un nouvel objet LatLng pour Google Maps avec les paramètres de position | |
latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); | |
// Ajout d'un marqueur à la position trouvée | |
var marker = new google.maps.Marker({ | |
position: latlng, | |
map: map, | |
title:"Vous êtes ici" | |
}); | |
// Permet de centrer la carte sur la position latlng | |
map.panTo(latlng); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment