Closed viliket closed 1 year ago
maplibre-gl 3.0.0 was released today and is the version that is pulled in by default now.
Proper workaround with the actual supported function would be to install:
npm install @mapbox/mapbox-gl-supported --save
And add it to the map implementation:
import maplibregl from 'maplibre-gl';
import { supported } from '@mapbox/mapbox-gl-supported';
const maplibreglWithSupported = { ...maplibregl, supported };
const MyMap = () => (
<Map mapLib={maplibreglWithSupported} />
);
Proper workaround with the actual supported function would be to install:
npm install @mapbox/mapbox-gl-supported --save
And add it to the map implementation:
import maplibregl from 'maplibre-gl'; import { supported } from '@mapbox/mapbox-gl-supported'; const maplibreglWithSupported = { ...maplibregl, supported }; const MyMap = () => ( <Map mapLib={maplibreglWithSupported} /> );
This is confirmed as working, Docs should be updated to reflect this method
I would still consider making react-map-gl not assuming/requiring the given mapLib
to have the supported
method at all as the original library has been stale for 3 years as mentioned in https://github.com/maplibre/maplibre-gl-js/discussions/2452#discussion-5134538
This library has not had any meaningful update for 3 years and is becoming stale. Anyone out there who still needs it can easily reference or add to their repo instead of using MapLibre as the middleman.
Otherwise everyone using react-map-gl with maplibre-gl is forced to either patch the map library object given to mapLib
either using the stale original library @mapbox/mapbox-gl-supported
or using a dummy implementation.
Fix published in v7.0.24.
Description
Upcoming maplibre-gl next major version 3 (maplibre-gl@3.0.0-pre.6) introduced the following breaking change: https://github.com/maplibre/maplibre-gl-js/pull/2451
This breaking change causes problems with
react-map-gl
because the Map component assumes that the usedmapLib
provides thesupported
method: https://github.com/visgl/react-map-gl/blob/9a5339f357840084d9dfd27a298d3ffe9f3e1176/src/components/map.tsx#L67Because of this issue, the map fails to display and throws the following error
Workaround
The issue can be circumvented using the following workaround:
Proposed solution
Map component line https://github.com/visgl/react-map-gl/blob/9a5339f357840084d9dfd27a298d3ffe9f3e1176/src/components/map.tsx#L67 could be changed to
so we do not test for supported if the
mapLib
does not provide it.Expected Behavior
Using the latest
maplibre-gl
asmapLib
should work withreact-map-gl
.Steps to Reproduce
See the following Code Sandbox to reproduce the behavior: https://codesandbox.io/s/jolly-sea-3ifhm8
Note that you can see that the problem in the Code Sandbox example can be circumvented by uncommenting the line
Environment
Logs
No response