-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Background
react-map-gl was originally created by Uber's visualization team to work with deck.gl. Aside from providing a React-friendly wrapper for Mapbox GL JS, it currently also addresses use cases including:
- Provide a base map layer for other visualization overlays, most extensively used in deck.gl and kepler.gl.
- A source of React map components without mapbox-gl dependency, including Marker, Popup and NavigationControl
The project was transferred to the Urban Computing Foundation in April 2020.
Issues with the current code base
Diverged dependencies
react-map-gl currently have two releases in production:
- v5.3 supports mapbox-gl v1 and maplibre-gl
- v6.1 supports mapbox-gl v2
The divergence happened when Mapbox changed its license, see #1380. It has become increasingly difficult to maintain as Maplibre and Mapbox start making more aggressive breaking changes.
Override of the native event handling
react-map-gl disables mapbox-gl's native event handling and implements its own. This is arguably the one most controversial design decision of this project, dated back to before the current maintainers were involved. Lengthy discussions have been had (e.g. #569, mapbox/mapbox-gl-js#3746, #725) and continues to generate hard-to-resolve feature requests (#574, #1640, #1353, #775) and performance issues (#1151, #909).
Despite major efforts to improve the usability of the custom controller, it still has many open issues. The code base is quite complex already, with few developers able to navigate and contribute. Considering the complexity of the task, it is unlikely for the current release to support Mapbox's non-WebMercator projection feature in its current state.
Proposal
This RFC is gathering feedback for the following major breaking changes proposed for react-map-gl v7.
- Make
mapbox-gla peer dependency so that the library is impartial about the version/fork used. - Drop the usage of mjolnir.js'
EventManagerand subsequentlyMapControlleraltogether. Instead, we will pursue exposing mapbox-gl's native event system and attempt to hijack the camera change under the hood. - This will allow users to use the latest rendering and interactive options when they are released by Mapbox.
- 3rd-party Mapbox addons will be supported by default.
- We can add a stateful version of MapGL that renders fully asynchronously without any performance impact.
- Remove transition interpolator classes and use native methods such as
Map.flyToandMap.easeTo. - Custom MapController classes will stop working.
- Remove the overlay classes.
- Components such as Marker, Popup etc. will no longer be mapbox-independent. We will use React portal to render them into mapbox-gl's control container, instead of floating outside of the map container. deck.gl applications that render these components as children of
DeckGLwill stop working. I propose we move some of the current code to a new React component library that is independent from mapbox-gl. - Rewrite the code base in TypeScript.
The goal is to have a code base that is less demanding to maintain, and more focused on the most common use cases. To achieve this, we have to drop some niche use cases and/or move their support to other projects.