Skip to content

Commit d57e469

Browse files
Remove support() check (#2508)
1 parent 2ab6131 commit d57e469

File tree

3 files changed

+30
-48
lines changed
  • modules
    • main/src/mapbox-legacy/components
    • react-mapbox/src/components
    • react-maplibre/src/components

3 files changed

+30
-48
lines changed

modules/main/src/mapbox-legacy/components/map.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
5959
throw new Error('Invalid mapLib');
6060
}
6161

62-
// workerUrl & workerClass may change the result of supported()
63-
// https://github.com/visgl/react-map-gl/discussions/2027
6462
setGlobals(mapboxgl, props);
65-
if (!mapboxgl.supported || mapboxgl.supported(props)) {
66-
if (props.reuseMaps) {
67-
mapbox = Mapbox.reuse(props, containerRef.current);
68-
}
69-
if (!mapbox) {
70-
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
71-
}
72-
contextValue.map = createRef(mapbox);
73-
contextValue.mapLib = mapboxgl;
74-
75-
setMapInstance(mapbox);
76-
mountedMapsContext?.onMapMount(contextValue.map, props.id);
77-
} else {
78-
throw new Error('Map is not supported by this browser');
63+
if (props.reuseMaps) {
64+
mapbox = Mapbox.reuse(props, containerRef.current);
7965
}
66+
if (!mapbox) {
67+
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
68+
}
69+
contextValue.map = createRef(mapbox);
70+
contextValue.mapLib = mapboxgl;
71+
72+
setMapInstance(mapbox);
73+
mountedMapsContext?.onMapMount(contextValue.map, props.id);
8074
})
8175
.catch(error => {
8276
const {onError} = props;

modules/react-mapbox/src/components/map.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
5959
throw new Error('Invalid mapLib');
6060
}
6161

62-
// workerUrl & workerClass may change the result of supported()
63-
// https://github.com/visgl/react-map-gl/discussions/2027
6462
setGlobals(mapboxgl, props);
65-
if (!mapboxgl.supported || mapboxgl.supported(props)) {
66-
if (props.reuseMaps) {
67-
mapbox = Mapbox.reuse(props, containerRef.current);
68-
}
69-
if (!mapbox) {
70-
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
71-
}
72-
contextValue.map = createRef(mapbox);
73-
contextValue.mapLib = mapboxgl;
74-
75-
setMapInstance(mapbox);
76-
mountedMapsContext?.onMapMount(contextValue.map, props.id);
77-
} else {
78-
throw new Error('Map is not supported by this browser');
63+
if (props.reuseMaps) {
64+
mapbox = Mapbox.reuse(props, containerRef.current);
7965
}
66+
if (!mapbox) {
67+
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
68+
}
69+
contextValue.map = createRef(mapbox);
70+
contextValue.mapLib = mapboxgl;
71+
72+
setMapInstance(mapbox);
73+
mountedMapsContext?.onMapMount(contextValue.map, props.id);
8074
})
8175
.catch(error => {
8276
const {onError} = props;

modules/react-maplibre/src/components/map.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
5959
throw new Error('Invalid mapLib');
6060
}
6161

62-
// workerUrl & workerClass may change the result of supported()
63-
// https://github.com/visgl/react-map-gl/discussions/2027
6462
setGlobals(mapboxgl, props);
65-
if (!mapboxgl.supported || mapboxgl.supported(props)) {
66-
if (props.reuseMaps) {
67-
maplibre = Maplibre.reuse(props, containerRef.current);
68-
}
69-
if (!maplibre) {
70-
maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current);
71-
}
72-
contextValue.map = createRef(maplibre);
73-
contextValue.mapLib = mapboxgl;
74-
75-
setMapInstance(maplibre);
76-
mountedMapsContext?.onMapMount(contextValue.map, props.id);
77-
} else {
78-
throw new Error('Map is not supported by this browser');
63+
if (props.reuseMaps) {
64+
maplibre = Maplibre.reuse(props, containerRef.current);
7965
}
66+
if (!maplibre) {
67+
maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current);
68+
}
69+
contextValue.map = createRef(maplibre);
70+
contextValue.mapLib = mapboxgl;
71+
72+
setMapInstance(maplibre);
73+
mountedMapsContext?.onMapMount(contextValue.map, props.id);
8074
})
8175
.catch(error => {
8276
const {onError} = props;

0 commit comments

Comments
 (0)