Skip to content

Instantly share code, notes, and snippets.

@RomainMaillot13
Created November 27, 2018 10:16
Show Gist options
  • Save RomainMaillot13/6fb058bbba66b8cc60d0b6178db63346 to your computer and use it in GitHub Desktop.
Save RomainMaillot13/6fb058bbba66b8cc60d0b6178db63346 to your computer and use it in GitHub Desktop.
connect to google map api
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