Skip to content

Commit

Permalink
Merge pull request #558 from apollomapping/transformrequest-mapoption
Browse files Browse the repository at this point in the history
add transformRequest map option
  • Loading branch information
alex3165 authored Mar 16, 2018
2 parents 77d9a97 + d00003a commit 24cdbf2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export interface State {
ready: boolean;
}

export type RequestTransformFunction = (url: string,
// tslint:disable-next-line:no-any
resourceType: any) => any;

// Static Properties of the map
export interface FactoryParameters {
accessToken: string;
Expand All @@ -90,6 +94,7 @@ export interface FactoryParameters {
classes?: string[];
bearingSnap?: number;
injectCss?: boolean;
transformRequest?: RequestTransformFunction;
}

// Satisfy typescript pitfall with defaultProps
Expand All @@ -105,6 +110,7 @@ declare global {
namespace mapboxgl {
export interface MapboxOptions {
failIfMajorPerformanceCaveat?: boolean;
transformRequest?: RequestTransformFunction;
}
}
}
Expand Down Expand Up @@ -132,7 +138,8 @@ const ReactMapboxFactory = ({
failIfMajorPerformanceCaveat = false,
classes,
bearingSnap = 7,
injectCss = true
injectCss = true,
transformRequest
}: FactoryParameters) => {
if (injectCss) {
injectCSS(window);
Expand Down Expand Up @@ -228,7 +235,8 @@ const ReactMapboxFactory = ({
logoPosition,
classes,
bearingSnap,
failIfMajorPerformanceCaveat
failIfMajorPerformanceCaveat,
transformRequest
};

if (bearing) {
Expand Down

0 comments on commit 24cdbf2

Please sign in to comment.