robertleeplummerjr / Leaflet.glify

fully functional, ridiculously fast web gl renderer plugin for leaflet
https://robertleeplummerjr.github.io/Leaflet.glify
MIT License
481 stars 85 forks source link

Is it possible to give L.glify.lines different colours? #141

Closed ahmedosman2001 closed 1 year ago

ahmedosman2001 commented 1 year ago

I'd like the line's colour to be based on the date the data was collected. For example, I'd like to assign one colour to all of the coordinates collected in week 1, another colour to week 2, and so on.

For example, this is simple GeoJSON data

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [
                [    -0.1,
                      0.2
                ],
                [
                    -0.2,
                     0.3
                ]]
            },
                "properties": [
                    {"r": 0,"g": 3, "b": 10}, 
                    {"r": 1,"g": 4, "b": 11}]
            }
        ]
}

In the example above, there are two coordinates (collected in week one and two) and two rgb colours. Is it possible to assign one colour to each coordinate. I'm attempting to accomplish this, so I tried the code below, but I keep getting white for all of the coordinates. I also tried the rgb in decimals (r: 0.0 g: 0.3 b:0.10) and it didn't work.

L.glify.lines({
    map: map,
    latitudeKey: 1,
    longitudeKey: 0,
    data: geojson,
    size: 2,
    color:  function(index, point) { return point.features[0].properties[index]; }
})