Skip to content

Commit

Permalink
[fix] Fix react-map-gl mapbox api props (#2362)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Oct 10, 2023
1 parent d0a8658 commit ec0881d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions babel-register.js
Expand Up @@ -44,6 +44,9 @@ require('@babel/polyfill');
var path = require('path');
var glob = require('glob');

// Requiring mapbox-gl here prevents polyfilling errors during tests.
require('mapbox-gl');

// eslint-disable-next-line func-names
process.argv.slice(2).forEach(function(arg) {
// eslint-disable-next-line func-names
Expand Down
4 changes: 4 additions & 0 deletions jest.setup.js
Expand Up @@ -21,6 +21,10 @@
import '@testing-library/jest-dom';
import * as Utils from '@kepler.gl/utils';

jest.mock('mapbox-gl/dist/mapbox-gl', () => ({
Map: () => ({})
}));

jest.mock('@kepler.gl/utils', () => ({
...jest.requireActual('@kepler.gl/utils'),
hasPortableWidth: jest.fn(),
Expand Down
8 changes: 6 additions & 2 deletions src/components/src/map-container.tsx
Expand Up @@ -979,8 +979,9 @@ export default function MapContainerFactory(
const mapProps = {
...internalViewState,
preserveDrawingBuffer: true,
mapboxApiAccessToken: currentStyle?.accessToken || mapboxApiAccessToken,
mapboxApiUrl,
mapboxAccessToken: currentStyle?.accessToken || mapboxApiAccessToken,
baseApiUrl: mapboxApiUrl,
mapLib: mapboxgl,
transformRequest: this.props.transformRequest || transformRequest
};

Expand Down Expand Up @@ -1065,6 +1066,9 @@ export default function MapContainerFactory(
viewState={internalViewState}
mapStyle={mapStyle.topMapStyle}
style={MAP_STYLE.top}
mapboxAccessToken={mapProps.mapboxAccessToken}
baseApiUrl={mapProps.baseApiUrl}
mapLib={mapboxgl}
{...topMapContainerProps}
/>
) : null}
Expand Down
5 changes: 3 additions & 2 deletions src/components/src/modals/add-map-style-modal.tsx
Expand Up @@ -175,8 +175,9 @@ function AddMapStyleModalFactory() {
const mapboxApiAccessToken = inputStyle.accessToken || this.props.mapboxApiAccessToken;
const mapProps = {
...mapState,
mapboxApiUrl,
mapboxApiAccessToken,
baseApiUrl: mapboxApiUrl,
mapboxAccessToken: mapboxApiAccessToken,
mapLib: mapboxgl,
preserveDrawingBuffer: true,
transformRequest
};
Expand Down

0 comments on commit ec0881d

Please sign in to comment.