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
|
var image='mmap.png';
//Les variables ci-dessous sont globales, pour être accessibles dans la fonction init_autocomplete, ou autre<br>//on passe les points de PHP à javascript via la fonction json_encode
var myLatLng = <?php echo json_encode($infos_geo,JSON_NUMERIC_CHECK)?>;
//un tableau pour enregistrer les markers
var markers = new Array();
//Vérifier tout de même qu'on a quelque chose dans le tableau
console.log(myLatLng);
for (var i=0 ; i<myLatLng.length ; i++){
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(myLatLng[0][0], myLatLng[0][1]),
map: map,
title:"Position Actuel",
// On définit l'icône de ce marker comme étant l'image définie juste au-dessus
icon: image
});
if (myLatLng[0]==myLatLng[i+1]){
delete myLatLng[i+1];
return myLatLng[0];
}
var marker = new google.maps.Marker({
position: new google.maps.LatLng(myLatLng[i+1][0], myLatLng[i+1][1]),
map: map,
title: 'Adresse n°'+i
});
markers.push(marker);
var flightPlanCoordinates = [
{lat: myLatLng[i][0], lng: myLatLng[i][1]},
{lat: myLatLng[i+1][0], lng: myLatLng[i+1][1]}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#0000FF',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
} |
Partager