mapbox / mapbox/mapbox-gl-js

Support clustering on vector tile data

Open
#10,408 7 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## Explanation

I'm fully aware we could use a `geojson` data source to accomplish this. Our datasets are large enough geographically that we would prefer to use tilesets instead if possible. We've found tilesets to be a much less bandwidth-intensive alternative for larger data sets like ours.

Mapbox is currently using their "supercluster" javascript plugin internally in the GL JS code in the browser. However, at the moment, it only works with a `geojson` data source. We would love that same functionality to be able to work with external tilesets [(`type: vector, tiles: ...`)](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/) as well.

## Reasoning

For now, we have implemented "supercluster" server-side as we write the tilesets to disk. We then read those in from the server and use clustering that way.

The problem with this approach is all about filtering. We can't really implement multiple filters on our data well with this approach. It works well for a single filter, but we want to be able to filter on multiple data points and server-side clustering does not work well for this approach.

## Implementation

You already have a [`cluster: true`](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/) option as part of `addSource()`. It only works with `geojson` sources is the issue. If you could allow it to work also with `type: vector` and `tiles: [url]` then my dream would be complete.

Thank you for your time and consideration.

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 addSource() handling for cluster: true and compare the existing GeoJSON path with vector sources using type: vector and tiles: [url]. Review how the current supercluster behavior handles filtering. Done means clustering works for vector tile sources while supporting multiple data filters.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.