Skip to content

Commit

Permalink
add: transform request
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneburdet committed Sep 27, 2023
1 parent 64ecd7f commit 089b858
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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;
export let aspectRatio: number;
Expand Down Expand Up @@ -47,7 +47,9 @@
}
// Lifecycle
onMount(() => map.initialize(style, container, { bounds: bbox as LngLatBoundsLike }));
onMount(() =>
map.initialize(style, container, { bounds: bbox as LngLatBoundsLike, transformRequest })
);
onDestroy(() => map.destroy());
</script>

Expand Down
6 changes: 5 additions & 1 deletion packages/visualizations/src/components/MapPoi/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CircleLayerSpecification, StyleSpecification, GeoJSONFeature } from 'maplibre-gl';
import type { CircleLayerSpecification, StyleSpecification, GeoJSONFeature, RequestTransformFunction } from 'maplibre-gl';
import type { BBox, GeoJsonProperties } from 'geojson';
import type { Color, Source } from '../types';
import type { CategoryLegend } from '../Legend/types';
Expand All @@ -16,6 +16,10 @@ 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 to map nda transform urls wherever they are called.
* 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 @@ -105,6 +105,7 @@ export const getMapOptions = (options: PoiMapOptions) => {
description,
legend,
sourceLink,
transformRequest,
} = options;
return {
aspectRatio,
Expand All @@ -115,5 +116,6 @@ export const getMapOptions = (options: PoiMapOptions) => {
description,
legend,
sourceLink,
transformRequest,
};
};

0 comments on commit 089b858

Please sign in to comment.