maplibregl/mapboxgl color transitions get lost after setPaintProperty

39 views Asked by At

I want my features to smoothly transition different to colors based on its data. For this I apply a map.setPaintProperty but then the 'fill-color-transition' property becomes lost, forever.. Some code from a Maplibre jsfiddle

Mapboxgl seems to have same issue https://jsfiddle.net/perikut/Lpgtx43v/9/

layer paint property:

      paint: {
        'fill-color-transition': {
            duration: 3700

        },
        'fill-color': 'blue',
        'fill-opacity': .6
    }

    //it properly smoothly changes the colors
    map.setPaintProperty('polygons-layer','fill-color','orange')

    map.setPaintProperty(
        'polygons-layer',
        'fill-color',
        [
            'match',
            ['get', 'id'],
            1, 'red',
            'gray' 
        ],
        'rgba(236, 235, 235, 0.1)' // Default color for all other cases
    );


    setTimeout(function() {
        //transition not working anymore 
        map.setPaintProperty('polygons-layer', 'fill-color', 'orange')
    }, 2000)
0

There are 0 answers