mapbox / mapbox/mapbox-gl-js

id inaccessible in clusterProperties expression

Open
#10,883 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation :mag:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 2.3.1

### Steps to Trigger Behavior

I have a GeoJSON layer whose source has both an `id` and an `id` property:

```
servicePoints.forEach((sp, i) => {
sp.id = i + 1;
sp.properties.id = i + 1;
});
```

I add a source defined like this:

```
map.U.addGeoJSON('results', undefined, {
cluster: true,
clusterRadius: 20,
clusterProperties: {
ids: ['concat', ['concat', ['id'], ',']],
ids2: ['concat', ['concat', ['get', 'id'], ',']],
orgNames: ['concat', ['concat', ['get', 'orgName'], ',']],
},
});
```

When I log the results of clicking on a clustered point:

```
properties: {
cluster: true
cluster_id: 33
ids: ",,"
ids2: "96,97,"
orgNames: "redacted,redacted"
point_count: 2
point_count_abbreviated: 2
}
```

### Expected Behavior

Expect `ids` to contain the same value as `ids2`.

### Actual behaviour

`['id']` seems to return empty string in a `clusterProperties` expression.

Maybe related issues: #10094, #8218, #10786

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

Start with the GeoJSON source setup and its clusterProperties expressions, comparing ['id'] with ['get', 'id'] using the reported mapbox-gl-js 2.3.1 reproduction. Review related issues #10094, #8218, and #10786; done means clustered features expose matching values for ids and ids2.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.