Skip to content

Commit

Permalink
[feat] Pass in custom transformRequest function (#2534)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta authored Mar 7, 2024
1 parent b644f20 commit 1f9757b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/components/src/kepler-gl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ export const mapFieldsSelector = (props: KeplerGLProps, index: number = 0) => ({

// mapStyle
topMapContainerProps: props.topMapContainerProps,
bottomMapContainerProps: props.bottomMapContainerProps
bottomMapContainerProps: props.bottomMapContainerProps,

// transformRequest for Mapbox basemaps
transformRequest: props.transformRequest
});

export function getVisibleDatasets(datasets) {
Expand Down Expand Up @@ -317,6 +320,8 @@ type KeplerGLBasicProps = {

topMapContainerProps?: object;
bottomMapContainerProps?: object;

transformRequest?: (url: string) => {url: string};
};

type KeplerGLProps = KeplerGlState & KeplerGlActions & KeplerGLBasicProps;
Expand Down
5 changes: 1 addition & 4 deletions src/utils/src/map-style-utils/mapbox-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export function isStyleUsingMapboxTiles(mapStyle) {
}

export const transformRequest = (url: string): {url: string} => {
const isMapboxRequest =
url.slice(8, 22) === 'api.mapbox.com' || url.slice(10, 26) === 'tiles.mapbox.com';

return {
url: isMapboxRequest ? url.replace('?', '?pluginName=Keplergl&') : url
url
};
};

0 comments on commit 1f9757b

Please sign in to comment.