React-map-gl: Map does not load or display anything in Electron

Created on 18 May 2019  路  6Comments  路  Source: visgl/react-map-gl

Hey, y'all.

I've been playing with the library this afternoon. I supplied my component with all of its props but nothing gets displayed. Anyone know what might be wrong?

<StaticMap
            width={400}
            height={400}
            zoom={8}
            onLoad={(a) => console.log('loaded', a)}
            onError={(e) => console.log('error!', e)}
            latitude={37.805}
            longitude={-122.447}
            mapStyle="mapbox://styles/mapbox/dark-v9"
            mapboxApiAccessToken='...'
          />

I get no errors, or anything, so I have no idea what is going wrong. Trying to render this map on an Electron app.

Most helpful comment

After two days of playing around with different electron-react boilerplates and _react-map-gl_, we finally found the issue creating the problem described above for us.
In our _webpack.config.js_ we had a line to exclude node modules from being bundled:
externals: [...Object.keys(dependencies || {})]
Apparently, _react-map-gl_ expect to be bundled (?) so we excluded it from the array:
externals: [...Object.keys(dependencies || {}).filter(x => x !== 'react-map-gl')] and voila we get the map in our electron map.

All 6 comments

I have the same issue - using a pretty bare app right now with fuse-box as the bundler, no network requests are firing off to MapBox so I feel like the MapBox sdk isn't being initialized/started. Testing the InteractiveMap's onLoad function isn't invoked either, so I suspect this is true

Using the MapBox SDK directly works fine

same here. webpack example works in Chrome, not working in Electron

After two days of playing around with different electron-react boilerplates and _react-map-gl_, we finally found the issue creating the problem described above for us.
In our _webpack.config.js_ we had a line to exclude node modules from being bundled:
externals: [...Object.keys(dependencies || {})]
Apparently, _react-map-gl_ expect to be bundled (?) so we excluded it from the array:
externals: [...Object.keys(dependencies || {}).filter(x => x !== 'react-map-gl')] and voila we get the map in our electron map.

@saschahofmann
Hope this works, i'll test it later. thx!

@Pessimistress i am having the same issue, the webpack workaround doesn't help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SethHamilton picture SethHamilton  路  3Comments

cjmyles picture cjmyles  路  3Comments

joseomar10 picture joseomar10  路  5Comments

sudoStatus200 picture sudoStatus200  路  5Comments

tbergman picture tbergman  路  3Comments