[Feat] Custom map.querySourceFeatues Renderer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.5k
- Forks
- 1.4k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 3
Description
Target Use Case
This feature is allows you to render content received via the querySourceFeatues function without worrying about React's lifecycle.
Example
Display HTML clusters with custom properties
- https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/
- https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/
Proposal
The QuerySourceFeatures (temporary name) component receives the arguments of the querySourceFeatures function, and additionally the target component that should be rendered via render.
Internally, the component references events for data, move, and moveend, and renders through the passed in render if any data has changed.
Here's example code to use
<QuerySourceFeatures
source="earthquakes"
filter={["==", "cluster", true]}
render={({ data }) => {
<Marker
longitude={data.geometry.coordinates[0]}
latitude={data.geometry.coordinates[1]}
>
<DonutChart properties={data.properties!} />
</Marker>
}}
/>
I've written POC code in the following repo.
If you think it's a good idea to add these features, please review them for further improvements and I'll write a PR.
Otherwise I'll PR that POC code as an example.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked POC repository and the cluster HTML examples to understand the proposed QuerySourceFeatures API. Compare its behavior with this proposal, including data, move, and moveend updates, and confirm that rendered querySourceFeatures content can follow React's lifecycle without manual handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100