diff --git a/modules/main/src/mapbox-legacy/components/map.tsx b/modules/main/src/mapbox-legacy/components/map.tsx index f6b4b29d6..4eb3d0a14 100644 --- a/modules/main/src/mapbox-legacy/components/map.tsx +++ b/modules/main/src/mapbox-legacy/components/map.tsx @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref) { throw new Error('Invalid mapLib'); } - // workerUrl & workerClass may change the result of supported() - // https://github.com/visgl/react-map-gl/discussions/2027 setGlobals(mapboxgl, props); - if (!mapboxgl.supported || mapboxgl.supported(props)) { - if (props.reuseMaps) { - mapbox = Mapbox.reuse(props, containerRef.current); - } - if (!mapbox) { - mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current); - } - contextValue.map = createRef(mapbox); - contextValue.mapLib = mapboxgl; - - setMapInstance(mapbox); - mountedMapsContext?.onMapMount(contextValue.map, props.id); - } else { - throw new Error('Map is not supported by this browser'); + if (props.reuseMaps) { + mapbox = Mapbox.reuse(props, containerRef.current); } + if (!mapbox) { + mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current); + } + contextValue.map = createRef(mapbox); + contextValue.mapLib = mapboxgl; + + setMapInstance(mapbox); + mountedMapsContext?.onMapMount(contextValue.map, props.id); }) .catch(error => { const {onError} = props; diff --git a/modules/react-mapbox/src/components/map.tsx b/modules/react-mapbox/src/components/map.tsx index 2e567b124..fbd52b399 100644 --- a/modules/react-mapbox/src/components/map.tsx +++ b/modules/react-mapbox/src/components/map.tsx @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref) { throw new Error('Invalid mapLib'); } - // workerUrl & workerClass may change the result of supported() - // https://github.com/visgl/react-map-gl/discussions/2027 setGlobals(mapboxgl, props); - if (!mapboxgl.supported || mapboxgl.supported(props)) { - if (props.reuseMaps) { - mapbox = Mapbox.reuse(props, containerRef.current); - } - if (!mapbox) { - mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current); - } - contextValue.map = createRef(mapbox); - contextValue.mapLib = mapboxgl; - - setMapInstance(mapbox); - mountedMapsContext?.onMapMount(contextValue.map, props.id); - } else { - throw new Error('Map is not supported by this browser'); + if (props.reuseMaps) { + mapbox = Mapbox.reuse(props, containerRef.current); } + if (!mapbox) { + mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current); + } + contextValue.map = createRef(mapbox); + contextValue.mapLib = mapboxgl; + + setMapInstance(mapbox); + mountedMapsContext?.onMapMount(contextValue.map, props.id); }) .catch(error => { const {onError} = props; diff --git a/modules/react-maplibre/src/components/map.tsx b/modules/react-maplibre/src/components/map.tsx index 7d8fe2ae1..1300d1200 100644 --- a/modules/react-maplibre/src/components/map.tsx +++ b/modules/react-maplibre/src/components/map.tsx @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref) { throw new Error('Invalid mapLib'); } - // workerUrl & workerClass may change the result of supported() - // https://github.com/visgl/react-map-gl/discussions/2027 setGlobals(mapboxgl, props); - if (!mapboxgl.supported || mapboxgl.supported(props)) { - if (props.reuseMaps) { - maplibre = Maplibre.reuse(props, containerRef.current); - } - if (!maplibre) { - maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current); - } - contextValue.map = createRef(maplibre); - contextValue.mapLib = mapboxgl; - - setMapInstance(maplibre); - mountedMapsContext?.onMapMount(contextValue.map, props.id); - } else { - throw new Error('Map is not supported by this browser'); + if (props.reuseMaps) { + maplibre = Maplibre.reuse(props, containerRef.current); } + if (!maplibre) { + maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current); + } + contextValue.map = createRef(maplibre); + contextValue.mapLib = mapboxgl; + + setMapInstance(maplibre); + mountedMapsContext?.onMapMount(contextValue.map, props.id); }) .catch(error => { const {onError} = props;