Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions modules/main/src/mapbox-legacy/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
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;
Expand Down
26 changes: 10 additions & 16 deletions modules/react-mapbox/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
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;
Expand Down
26 changes: 10 additions & 16 deletions modules/react-maplibre/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,18 @@ function _Map(props: MapProps, ref: React.Ref<MapRef>) {
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;
Expand Down
Loading