File tree Expand file tree Collapse file tree 3 files changed +30
-48
lines changed
main/src/mapbox-legacy/components
react-mapbox/src/components
react-maplibre/src/components Expand file tree Collapse file tree 3 files changed +30
-48
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments