OpenLayers 8.1 apply FlatStyle conditionally

111 Views Asked by At

I am trying to figure out how to apply a FlatStyle to a feature conditionally as I am using WebGL to render my features.

The API describes that you can use an array of rules, however I can't find an example of the rules being used.

I have tried to modify the official WebGL points layer example to use the code example from the API, however nothing renders.

My assumption was to pass the array of rules to the style property of the WebGLPointsLayer like so:

const rules = [
  {
    filter: ['>', 'population', 1000000],
    style: {
      'circle-radius': 10,
      'circle-color': 'red',
    }
  },
  {
    else: true,
    style: {
      'circle-radius': 5,
      'circle-color': 'blue',
   },
 ];

var pointsLayer = new WebGLPointsLayer({
    source: vectorSource,
    style: rules,
  });

This doesn't seem to be the correct way to apply the rules but again, I can't find any example or documentation on how to use them.

0

There are 0 best solutions below