Closed paulobraga closed 9 years ago
Hi,
check out the options for L.Routing.Line
. You want to change the styles
option.
To do this from the control, change its lineOptions
. You can see an example with code here: http://www.liedman.net/leaflet-routing-machine/styling.html
Hi, the url http://www.liedman.net/leaflet-routing-machine/styling.html not work, but I found this page http://trustdarkness.com/wordpress/leaflet-routing-machine-custom-icons-and-custom-lines/ It works.
bye
For future people looking for a fast solution, based on @DiegoJohan link:
Find out the solution!
L.Routing.control({
waypoints: waypoints,
lineOptions: {
styles: [{color: 'white', opacity: 1, weight: 5}]
}
}).addTo(this.map)
I am printing route on map but i need doted line so plz tell about doted style
@MayurDynamo LRM uses Leaflet's standard options for styling lines. You likely want to use the dasharray
option.
Thank you a got this solution. My problem is solved
How to change the route line color in leaflet when it is already added to map
you can try a dirty solution, by changing the style on the routesfound event,
on('routesfound', (e) => {
if (e !== undefined && e.routes !== undefined && e.routes.length > 0){
e.sourceTarget.options.lineOptions.styles[0].color = "blue";
}
}
btw amazing control, thanks!
Hi,
I want to change route color when I click on Start or End marker, how is it possible ? https://www.lamaraudiere.com/d4ua/cartographie.php
I saw you managed to change the route color, @BenLaKnet . Can you tell how you did that?
Hi,
I create a new issue: https://github.com/perliedman/leaflet-routing-machine/issues/654
thx this help me!!!
Hello,
I would like to change the route line color to blue, the default is red, how can I do?
my code looks like: