mapbox / mapbox/mapbox-gl-js

Get properties of the best/max element with cluster properties

Open
#8,613 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

mapbox-gl-js version: 1.2.0

Question

I have a GeoJSON feature collection of points which I'm clustering, with the following properties:

properties: {
   name: string,
   value: number,
}

I'm trying to get in the clusterProperties the name with the highest value. I've managed to get the max value using the following expression: ['max', ['get', 'value']], but I don't know how to get the name or other fields of the best element.

How should this expression be written?

Links to related documentation

https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-max
https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-get

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the linked style-spec sections for max and get, then trace how clusterProperties expressions are handled in the v1.2.0 codebase. Determine whether the name can be retrieved with the maximum value, including the expected behavior for ties. Done means the supported expression or limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.