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 57 58 59 60 61 62 63 64 65
| var directionDisplay;
var map;
var sites = [<?php echo $data; ?>];
var infowindow = null;
var markers = new Array(); // Stockage des markers
// Initialisation de la carte
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
mapTypeId: google.maps.MapTypeId.SATELLITE
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
setZoom(map, sites);
setMarkers(map, sites);
directionsDisplay.setMap(map);
infowindow = new google.maps.InfoWindow({
maxWidth: 320,
});
}
/*
Affichage des marqueurs avec les infowindows
*/
function setMarkers(map, markers) {
var image = {
url: '../../../images/pic8.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(20, 36),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(16, 36)
};
for (var i = 0; i < markers.length; i++) {
var Action = document.getElementById(sites[0]);
var site = markers[i];
var siteLatLng = new google.maps.LatLng(site[2], site[3]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: site[0],
icon: image,
html: site[4],
// Effet pour laisser les marqueurs tomber
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(marker, "click", function() {
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
}
/*
Zoom sur les marqueurs de la carte
*/
function setZoom(map, markers) {
var boundbox = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
boundbox.extend(new google.maps.LatLng(markers[i][2], markers[i][3]));
}
map.setCenter(boundbox.getCenter());
map.fitBounds(boundbox);
} |
Partager