Both mentioned projects use an custom L.Renderer for coloring a polyline segments. You can takeusing this renderer and use(if it is possible) to color the GeoJSON object usingvia the style
option as follows:
var polyline = L.geoJSON(geoJSONdata,{
style: function(feature){
return {
renderer: new polycolorRendererL.Renderer.RendererGradient(),
....colors: colorsArray, // options for renderer
weight: 5 // options for polyline
}
}
}).addTo(map);
Here we use a renderer from leaflet-polycolor that allows do it.
However, I tookextracted the renderer from leaflet-polycolor project and put it in a separate git repo withbecause the size of the renderer alone is almost four times smaller than the entire project. The comments and samples included.
But it seems to me that using a renderer is an overkill for such task. But there is no other way.