mapbox / mapbox-directions.js

Leaflet plugin for the Mapbox Directions API
https://www.mapbox.com/mapbox.js/example/v1.0.0/mapbox-directions/
ISC License
60 stars 23 forks source link

is it possible to customize the path styles for different profiles? #80

Closed tumluliu closed 9 years ago

tumluliu commented 9 years ago

I would like to set different styles for different types of path, e.g. black solid line for driving path, blue line for cycling, dashed line for walking, etc.

I tried adding a style function for the routeLayer in layer.js like this:

this.routeLayer = L.geoJson(null, { style: myStyle });
this.routeHighlightLayer = L.geoJson(null, { style: myStyle });

But it does not work. The path is always in '#3bb2d0', 4px width and 0.75 opacity which is defined by path.leaflet-clickable in mapbox.directions.css.

tumluliu commented 9 years ago

Solved by just removing the path.leaflet-clickable section.

Is it the right way?

jfirebaugh commented 9 years ago

Yeah, removing that CSS is a good workaround. In 2f5ee4dd281bd21706ee9c5d087c2c4b8da6f527 I've removed it and made the route layer style configurable.

tumluliu commented 9 years ago

Great to see the codes in the commit. Many thanks, jfirebaugh.