Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for ( i = 0 ; i < locations.length; i++ )
- {
- var marker = locations[i][5];
- var name = locations[i][0];
- directionsService.route
- (
- {
- origin: <?php echo "'$zip'"; ?>,
- destination: new google.maps.LatLng(locations[i][2],locations[i][3]) ,
- travelMode: 'DRIVING'
- }, function(response, status)
- {
- if (status === 'OK')
- {
- var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
- directionsDisplay.setMap(map) ;
- directionsDisplay.setDirections(response);
- directionDisplays.push(directionsDisplay) ;
- alert(name);
- google.maps.event.addListener(marker, 'click', (function(marker, i)
- {
- return function()
- {
- var point = response.routes[ 0 ].legs[ 0 ];
- infowindow.setContent('<b><center>' + name + '</center></b><br>' + '<b>Temps estimé:</b> ' + point.duration.text + '<br><b>Distance: </b>' + point.distance.text);
- infowindow.open(map, marker);
- }
- })(marker, i));
- }
- else
- {
- window.alert('Directions request failed due to ' + status);
- }
- }
- );
- }
Add Comment
Please, Sign In to add comment