Expression to filter on feature geometry type #405
Answered
by
sargunv
jg-develop
asked this question in
Q&A
-
I have a geojson file which contains two types of feature, some "points" and some "LineStrings". I have created a SymbolLayer to render the features, but I only want to render the Points not the lines, so I am trying to filter, but I can't work out the filter expression to use? I only want to show features where geometry.type == "Point". My JSON is:
My code is: SymbolLayer(
id = "foo",
source = fooSource,
filter = feature.??????
onClick = { features ->
selectedFeature = features.firstOrNull()
ClickResult.Consume
},
iconImage = image(marker),
) Is anyone able to point me in the right direction please? |
Beta Was this translation helpful? Give feedback.
Answered by
sargunv
Jun 3, 2025
Replies: 1 comment 1 reply
-
I think you want something like: SymbolLayer(
filter = feature.type() eq const(GeometryType.Point)
....
) Docs:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sargunv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you want something like:
Docs:
eq()
: https://maplibre.org/maplibre-compose/api/lib/maplibre-compose-expressions/dev.sargunv.maplibrecompose.expressions.dsl/eq.htmlfeature.type()
: https://maplibre.org/maplibre-compose/api/lib/maplibre-compose-expressions/dev.sargunv.maplibrecompose.expressions.dsl/-feature/type.htmlconst()
: https://maplibre.org/maplibre-compose/api/lib/maplibre-compose-expressions/dev.sargunv.maplibrecompose.expressions.dsl/const.htmlGeometryType
: https://maplibre.org/maplibre-compose/api/lib/maplibre-compose-expressions/dev.sargunv.maplibrecompose.expressions.value/-geometry-type/inde…