Open
Conversation
|
@junwen-k is attempting to deploy a commit to the anmolsaini16's projects Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Jan 5, 2026
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.
Overview
In this PR, I’ve explored refactoring the map components to build on top of react-map-gl (I’ve added this as a separate
map-gl.tsxunder registry for comparison) rather than working directly with MapLibre GL. While this is a significant architectural change, but in my opinion, a more declarative API could help improve code clarity, maintainability, and overall developer experience.Addresses: #24
Example Comparison
Additional Context
While refactoring the map components, I've also discovered a few potential issues in the original implementation.
Fixed ID collision bug: The original implementation in
MapRoutecomponent had a bug wheresourceIdandlayerIdcould end up with identical IDs if anidprop was passed, leading to potential conflicts.Smarter interactive behavior: Instead of requiring a separate
interactiveprop forMapRoutecomponent, we can infer it from theonClickprop to dynamically handle the cursor style.To allow internal and external consumers to manage the map ref, I’ve inlined Radix UI’s
useComposedRefsutility. We can consider adding this as a shared dependency within the registry for consistency and future reuse.Rationale and Motivation
While I realize this is a significant refactor and may not be feasible to merge directly, I wanted to share it with the community in case others find value in a more declarative approach. My motivation came from building custom integrations where I didn't want to manage all the map reactivity imperatively, naturally leading me to consider
react-map-gl. I refactoredmapcnto see if it could also be built on top ofreact-map-gl. I hope this PR sparks inspiration among the community or inspires new integrations.Note
I only roughly updated the docs without going through every detail. My changes were mostly focused on getting the example to work and I didn't put too much effort into the rest of the documentation.