Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fix react-map-gl mapbox api props #2362

Merged
merged 3 commits into from
Oct 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel-register.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,9 @@ export default function MapContainerFactory(
const mapProps = {
...internalViewState,
preserveDrawingBuffer: true,
mapboxApiAccessToken: currentStyle?.accessToken || mapboxApiAccessToken,
mapboxApiUrl,
mapboxAccessToken: currentStyle?.accessToken || mapboxApiAccessToken,
baseApiUrl: mapboxApiUrl,
mapLib: mapboxgl,
Copy link
Collaborator Author

@igorDykhta igorDykhta Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyabo looks like we need to set mapLib in order to be able to set baseApiUrl (visgl/react-map-gl#1990 (comment))

transformRequest: this.props.transformRequest || transformRequest
};

Expand Down Expand Up @@ -1063,6 +1064,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
Original file line number Diff line number Diff line change
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