Skip to main content
added 254 characters in body
Source Link

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.

Both mentioned projects use an custom L.Renderer for coloring a polyline segments. You can take this renderer and use it to color the GeoJSON object using the style option as follows:

var polyline = L.geoJSON(geoJSONdata,{
    style: function(feature){
        return {
            renderer: new polycolorRenderer(),
            .... // options for renderer
        }
    }
}).addTo(map);

I took the renderer from leaflet-polycolor project and put it in a separate git repo with comments and samples.

But it seems to me that using a renderer is an overkill for such task. But there is no other way.

Both mentioned projects use an custom L.Renderer for coloring a polyline segments. You can using this renderer (if it is possible) to color the GeoJSON object via the style option as follows:

var polyline = L.geoJSON(geoJSONdata,{
    style: function(feature){
        return {
            renderer: new L.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 extracted the renderer from leaflet-polycolor and put it in a separate git repo because 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.

Source Link

Both mentioned projects use an custom L.Renderer for coloring a polyline segments. You can take this renderer and use it to color the GeoJSON object using the style option as follows:

var polyline = L.geoJSON(geoJSONdata,{
    style: function(feature){
        return {
            renderer: new polycolorRenderer(),
            .... // options for renderer
        }
    }
}).addTo(map);

I took the renderer from leaflet-polycolor project and put it in a separate git repo with comments and samples.

But it seems to me that using a renderer is an overkill for such task. But there is no other way.