fix: set projection after MapLibre styles load#1008
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📊 Coverage ReportsCoverage Changes by PackageClick to expand 29 package details
Coverage data collected from all packages in the monorepo. |
| <MapControls id={id} mapRef={mapRef} rbzRef={rbzRef} /> | ||
| )} | ||
| <MapProvider id={id}> | ||
| <MapLibre |
There was a problem hiding this comment.
Did you see this prop on the MapLibre component? https://visgl.github.io/react-map-gl/docs/api-reference/maplibre/map#projection
There was a problem hiding this comment.
That's the original (buggy) code - projection was being set above in the mapOptions to match the cameraState.projection value.
| // Spread order: default → consumer overrides → locked keys (last wins). | ||
| // | ||
| // Don't add MapLibre options here whose setter requires `isStyleLoaded()` | ||
| // (e.g. setProjection, setLight, setTerrain, setSky). react-map-gl applies |
There was a problem hiding this comment.
This is not true potentially?
inside style.load ->
https://github.com/visgl/react-map-gl/blob/master/modules/react-maplibre/src/maplibre/maplibre.ts#L323
this is also called in https://github.com/visgl/react-map-gl/blob/master/modules/react-maplibre/src/maplibre/maplibre.ts#L198 which should only be called, I believe, once a deckgl layer is added.
There was a problem hiding this comment.
updated to be more specific to projection issue.
|
|
||
| // `setProjection` throws if called before the style is loaded. Initial | ||
| // application happens in `handleMapLoad`; this effect syncs later changes. | ||
| useEffect(() => { |
There was a problem hiding this comment.
I am still slightly curious as to why this isn't an issue in the baseline react-map-gl package 🤔 still leading me to believe we are chasing a potential red herring or something.
Closes https://gitlab.accelint.dev/core-ux/standard-toolkit/-/issues/114
Maureen noticed an issue that arose after the PR to expose mapLibreOptions where, when setting the defaultView to 3D on the BaseMap, MapLibre would error with the following:
This PR waits to set projection until after the style has been loaded to avoid the error.
✅ Pull Request Checklist
📝 Test Instructions
maingo to the next app BaseMap and set thedefaultViewto3D:❓ Does this PR introduce a breaking change?
🤖 AI Usage
If ai was used, select all that apply:
💬 Other information