Allow more than 8 stops in simpleRenderer visual variable

243
0
10-02-2023 06:54 AM
Status: Open
Nicolas_
New Contributor III

Add ability to allow for more than 8 stop in the visual variable of a simple renderer.

For exemple in this code:

 

let rendererTemperature = new SimpleRenderer( {

    symbol: new SimpleMarkerSymbol({
        style: "circle",
        color: [250, 250, 250],
        outline: {
            color: [255, 255, 255, 0],
            width: 0.5
        },
        size: "8px"
    }),

    visualVariables: [
        new ColorVariable( {
            field: "TEMPERATURE",
            stops: [
                // Limited to 8 stops
                { value: 35, color: new Color([185, 7, 0, 255]) },
                { value: 20, color: new Color([241, 87, 0, 255]) },
                { value: 10, color: new Color([255, 200, 1, 255]) },
                { value: 5, color: new Color([253, 253, 118, 255]) },
                { value: -5, color: new Color([106, 221, 243, 255]) },
                { value: -10, color: new Color([49, 179, 244, 255]) },
                { value: -25, color: new Color([62, 121, 247, 255]) },
                { value: -40, color: new Color([90, 42, 215, 2555]) },
            ]
        })
    ]
});

 

 

 

Reasoning: While it is generally not recommanded to have too many different colors on a map, there can be use cases where having more stop is helpful. For exemple, when showing temperatures in a region where the annual variation is important. The same renderer in used for winter temperature (that can go as low as -40celcius) and summer ones (that can go as high as 35 celcius), but only a portion of the renderer "stops" will be seen for a given moment of the year. Being limited to only 8 stops means that for a given day of the year, only about 1 or 2 stops will be seen and we won't be able to distinguish regional temperature variations.

 

NOTE: JS api 4.x