Repository navigation
feat(ShapeSource): add clusterMinPoints - #4395
Merged
Merged
Conversation
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1955
Added
clusterMinPointstoShapeSource: the minimum number of points needed to form a cluster (default 2). It maps 1:1 to iOSGeoJSONSource.clusterMinPointsand AndroidGeoJsonSource.Builder.clusterMinPoints(Long), both available since SDK 11.5, so it works on the current default 11.23.1. It is also passed through on web (mapbox-glclusterMinPoints) and when reading a GeoJSON source fromStyleJSON.Like
clusterRadius, the value is applied when the source is created. I tried a livesetSourceProperty("clusterMinPoints")and the core rejected it on iOS (Cannot set property 'clusterMinPoints' for the source), so changing the value means remounting the ShapeSource. The prop docs say so.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
The Earthquakes example now has a button that switches
clusterMinPointsbetween 2 and 10, remounting the source viakey. I tested it on the iOS simulator (iPhone 17 Pro, iOS 26.5) and an Android emulator (Pixel 6). Both behaved the same. At 2 the map shows the usual clusters of 5, 8 and 9 points. At 10 those groups render as individual points, and only clusters of 10 or more remain (274/275, 39/40, 17/18). Switching back to 2 restores the original clusters.