Clustering: build an array with clusterProperties
#2160
Unanswered
antoinematyja
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Can you describe a use case from a user point of view? I'm having a hard time understanding the problem statement here. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am using the clustering feature and I would like to get on each cluster a property with an array of its clustered marker ids.
Looks like the best solution is to use the
map
/reduce
options ofSupercluster
, which are kind of tunable using theclusterProperties
parameter of the maplibre GL source:https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/#geojson-clusterProperties
However it seems like it is not possible to build an array: it relies on expressions which are translated into functions called in supercluster map/reduce, but there is no "accumulator" operator that builds an array.
I found nothing on this repository, but on mapbox-gl-js there is this issue:
mapbox/mapbox-gl-js#10695
Which was rejected by the author for some obscure reason (at least to me) – he probably missed use cases where this is useful.
I can think of 2 solutions:
Add an "accumulator" operator to the expressions framework that allows to build an array
This way the clustering code does not need any change
Allow to provide directly map/reduce functions to
clusterProperties
(in addition to expressions), for example:Let me know if I'm heading in the right direction 🙂
Beta Was this translation helpful? Give feedback.
All reactions