1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
{% for key, address in tabAdresses %}
{% set tabAdresses = [ address.nom , address.adresse , address.codePostal , address .commune ]|join(',') %} <br>
{{tabAdresses}}
{% endfor %}
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAo2ucdv4bbpkfEkJNfK-EngnR4Ag83OoA">
</script>
<script>
function initialize() {
//Création de la carte
var mapProp = {
center:new google.maps.LatLng(43.9088696,-0.3184784),
zoom:8,
mapTypeId: google.maps.MapTypeId.HYBRID
};
//Déclaration du Geocoder
var geocoder = new google.maps.Geocoder();
//Définition des paramètres récupérés
var address = '{{tabAdresses}}';
//Fonction du Géocoder
for (i = 0; i < 5; i++) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
var infowindow = new google.maps.InfoWindow({
content:"{{tabNom}}"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script> |
Partager