Akash
unread,Sep 1, 2010, 5:48:05 AM9/1/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Maps JavaScript API v3
Hi,
Following code was not working for me
var polylineOptions = {
map: map,
strokeColor: color,
strokeOpacity: "#FF0000",
strokeWeight: 4
}
directionsDisplay = new
google.maps.DirectionsRenderer({ polylineOptions: polylineOptions });
directionsDisplay.setMap(map);
directionsDisplay.setDirections(response);
and I found following workaround. I hope it will help others.
Thanks,
-Akash
if (status == google.maps.DirectionsStatus.OK) {
var polylineOptions = new
google.maps.Polyline({ strokeColor: color, strokeWeight: 1 });
directionsDisplay = new
google.maps.DirectionsRenderer({ polylineOptions: polylineOptions });
directionsDisplay.setMap(map);
directionsDisplay.setDirections(response);
var legs = response.routes[0].legs;
for (var leg = 0; leg < legs.length; leg++) {
for (var step = 0; step < legs[leg].steps.length;
step++) {
if (legs[leg].steps[step].lat_lngs) {
var polylineOptions = {
map: map,
strokeColor: color,
strokeOpacity: 0.7,
strokeWeight: 4,
path: legs[leg].steps[step].lat_lngs
}
new google.maps.Polyline(polylineOptions);
}
}
}