Open tordans opened 4 months ago
However, the code it shows
filter: ['in', '$type', 'Point']
does not represent a good case forin
. It is a simple "match" condition, not an array lookup nor a substring match.
This appears to be an example of the legacy in
filter, which is incompatible with expressions. So it’s ironic that it’s being given as an example of how to use the in
expression operator.
Feel free to submit a PR, either to this repo or maplibre gl where the example is.
The https://maplibre.org/maplibre-gl-js/docs/examples/measure/ example is referenced in https://maplibre.org/maplibre-style-spec/expressions/#in as a good way to learn how
in
works.However, the code it shows
filter: ['in', '$type', 'Point']
does not represent a good case forin
. It is a simple "match" condition, not an array lookup nor a substring match.Can we change this example to using
["all", ["match", ["geometry-type"], ["Polygon"], true, false]]
or["all", "$type", ["Polygon"], true, false]]
or ["==", "$type", "Polygon"] or something like this?See also https://github.com/maplibre/maplibre-style-spec/pull/664
This would mean we don't have an
in
example anymore (which I would argue we don't have now, either). I would consider something like https://visgl.github.io/react-map-gl/examples/filter (Code) a better fit. But even better would be a case with a['literal', ['array']]
IMO.