Skip to content

Commit

Permalink
add: transform request
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneburdet authored and KevinFabre-ods committed Sep 28, 2023
1 parent 7a6eaae commit 216384c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/visualizations/src/components/MapPoi/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
sourceLink,
aspectRatio,
interactive,
transformRequest,
} = getMapOptions(options));
const bbox = createDeepEqual(_bbox);
Expand All @@ -58,6 +59,7 @@
{sourceLink}
{aspectRatio}
{interactive}
{transformRequest}
/>
{/key}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export let style: MapOptions['style'];
export let sources: StyleSpecification['sources'];
export let layers: StyleSpecification['layers'];
export let transformRequest: MapOptions['transformRequest'];
// Options
export let bbox: BBox | undefined;
Expand Down Expand Up @@ -51,6 +52,7 @@
const options = {
bounds: bbox as LngLatBoundsLike,
...getCenterZoomOptions({ zoom, center }),
transformRequest,
};
map.initialize(style, container, options);
});
Expand Down
9 changes: 9 additions & 0 deletions packages/visualizations/src/components/MapPoi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
StyleSpecification,
GeoJSONFeature,
LngLatLike,
RequestTransformFunction,
} from 'maplibre-gl';
import type { BBox, GeoJsonProperties } from 'geojson';

Expand All @@ -22,6 +23,14 @@ export interface PoiMapOptions {
* - Or an object with a 'sources' and a 'layers' keys. Useful when using a Raster or WMS basemap.
*/
style?: string | PoiMapStyleOption;
/**
* A callback run before the Map makes a request for an external URL.
* The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.
* Expected to return an object with a url property and optionally headers and credentials properties.
*
* Especially useful for mapbox://
*/
transformRequest?: RequestTransformFunction;
/**
* Maximum boundaries of the map, outside of which the user cannot zoom/move
* Also set the position of the map when rendering.
Expand Down
2 changes: 2 additions & 0 deletions packages/visualizations/src/components/MapPoi/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const getMapOptions = (options: PoiMapOptions) => {
description,
legend,
sourceLink,
transformRequest,
} = options;
return {
aspectRatio,
Expand All @@ -120,6 +121,7 @@ export const getMapOptions = (options: PoiMapOptions) => {
description,
legend,
sourceLink,
transformRequest,
};
};

Expand Down

0 comments on commit 216384c

Please sign in to comment.