From d001fc1913914eb1c877dfee824a989a6c69f05e Mon Sep 17 00:00:00 2001 From: Etienne Burdet Date: Mon, 9 Oct 2023 11:47:49 +0200 Subject: [PATCH] Add min max zoom options --- packages/visualizations/src/components/MapPoi/Map.svelte | 6 +++++- .../visualizations/src/components/MapPoi/MapRender.svelte | 4 ++++ packages/visualizations/src/components/MapPoi/types.ts | 2 ++ packages/visualizations/src/components/MapPoi/utils.ts | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/visualizations/src/components/MapPoi/Map.svelte b/packages/visualizations/src/components/MapPoi/Map.svelte index 9602d19b..9a4cdf70 100644 --- a/packages/visualizations/src/components/MapPoi/Map.svelte +++ b/packages/visualizations/src/components/MapPoi/Map.svelte @@ -24,8 +24,10 @@ $: ({ bbox: _bbox, - zoom, center: _center, + zoom, + minZoom, + maxZoom, title, subtitle, description, @@ -52,6 +54,8 @@ bbox={$bbox} center={$center} {zoom} + {minZoom} + {maxZoom} {title} {subtitle} {description} diff --git a/packages/visualizations/src/components/MapPoi/MapRender.svelte b/packages/visualizations/src/components/MapPoi/MapRender.svelte index 3eef5808..e476ca25 100644 --- a/packages/visualizations/src/components/MapPoi/MapRender.svelte +++ b/packages/visualizations/src/components/MapPoi/MapRender.svelte @@ -22,6 +22,8 @@ // Options export let bbox: BBox | undefined; export let zoom: number | undefined; + export let minZoom: number | undefined; + export let maxZoom: number | undefined; export let center: LngLatLike | undefined; export let aspectRatio: number; export let interactive: boolean; @@ -53,6 +55,8 @@ bounds: bbox as LngLatBoundsLike, ...getCenterZoomOptions({ zoom, center }), transformRequest, + minZoom, + maxZoom, }; map.initialize(style, container, options); }); diff --git a/packages/visualizations/src/components/MapPoi/types.ts b/packages/visualizations/src/components/MapPoi/types.ts index fc8b99f5..2257838a 100644 --- a/packages/visualizations/src/components/MapPoi/types.ts +++ b/packages/visualizations/src/components/MapPoi/types.ts @@ -38,6 +38,8 @@ export interface PoiMapOptions { bbox?: BBox; center?: LngLatLike; zoom?: number; + minZoom?: number; + maxZoom?: number; // Aspect ratio used to draw the map. The map will take he width available to it, and decide its height based on that ratio. aspectRatio?: number; // Is the map interactive for the user (zoom, move, tooltips...) diff --git a/packages/visualizations/src/components/MapPoi/utils.ts b/packages/visualizations/src/components/MapPoi/utils.ts index befcffe8..064b9709 100644 --- a/packages/visualizations/src/components/MapPoi/utils.ts +++ b/packages/visualizations/src/components/MapPoi/utils.ts @@ -101,6 +101,8 @@ export const getMapOptions = (options: PoiMapOptions) => { aspectRatio = DEFAULT_ASPECT_RATIO, bbox, zoom, + maxZoom, + minZoom, center, interactive = true, title, @@ -114,6 +116,8 @@ export const getMapOptions = (options: PoiMapOptions) => { aspectRatio, bbox, zoom, + minZoom, + maxZoom, center, interactive, title,