i've integrated a map and i want to display the route directions between two locations.
everything is working fine and the directions is displayed perfectly ,
but i want to change the color of the Polyline
direction ,i've tried this code like the documentation says :
//polyline options
var pOptions = {
map: map,
strokeColor: "#2249a3",
strokeOpacity: 0.9 ,
strokeWeight: 12,
z-index: 99
};
logJava(polylineOptions);
//directionsRenderer options
var mDirectionsRendererOptions = {
map: map,
suppressMarkers: true,
suppressInfoWindows: true,
polylineOptions: pOptions
};
logJava(mDirectionsRendererOptions);
directionsDisplay = new google.maps.DirectionsRenderer(mDirectionsRendererOptions);
but when i add this code , it stops the map , and it displays nothing, when i comment it , everything is working fine .
what is wrong with this code, and how to change the color of the polyline with google maps javascript api v3 ?
Thanks in advance,
At global declarations
var polylineOptionsActual = new google.maps.Polyline({
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 10
});
At initialise
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer({polylineOptions: polylineOptionsActual});
In answer marked as resolved I see that object Polyline used for polylineOptions. In my case I use the next code
new google.maps.DirectionsRenderer({ suppressMarkers: true, polylineOptions: { strokeColor: '#5cb85c' } });
The difference is that I assign polylineOptions, not Polyline object. Not sure it could be helpful, but decided to add these answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With