From 520a97b4c1a9066cd8d9e15ddb587ef20bf1d48e Mon Sep 17 00:00:00 2001 From: ChristophMaskos <148751670+ChristophMaskos@users.noreply.github.com> Date: Mon, 25 Mar 2024 10:29:07 +0100 Subject: [PATCH] Introduce ZoomOptions-type (#298) --- .changeset/pretty-pillows-hunt.md | 6 ++++++ src/packages/map/api/MapModel.ts | 11 +++++++---- src/packages/map/model/Highlights.ts | 5 +++-- src/packages/result-list/ResultList.test.tsx | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 .changeset/pretty-pillows-hunt.md diff --git a/.changeset/pretty-pillows-hunt.md b/.changeset/pretty-pillows-hunt.md new file mode 100644 index 00000000..f13e3038 --- /dev/null +++ b/.changeset/pretty-pillows-hunt.md @@ -0,0 +1,6 @@ +--- +"@open-pioneer/result-list": minor +"@open-pioneer/map": minor +--- + +Introduce ZoomOptions-type diff --git a/src/packages/map/api/MapModel.ts b/src/packages/map/api/MapModel.ts index d3a0c010..eec076a9 100644 --- a/src/packages/map/api/MapModel.ts +++ b/src/packages/map/api/MapModel.ts @@ -18,7 +18,7 @@ export interface MapModelEvents { "destroy": void; } -/** Options supported when creating a new {@link Highlight}. */ +/** Styleoptions supported when creating a new {@link Highlight}. */ export interface HighlightOptions { /** * Optional styles to override the default styles. @@ -26,8 +26,8 @@ export interface HighlightOptions { highlightStyle?: HighlightStyle; } -/** Options supported by the map model's {@link MapModel.highlightAndZoom | zoom | highlightAndZoom} method. */ -export interface HighlightZoomOptions extends HighlightOptions { +/** Zoomoptions supported when creating a new {@link Highlight}. */ +export interface ZoomOptions { /** * The zoom-level used if there is no valid extend (such as for single points). */ @@ -44,6 +44,9 @@ export interface HighlightZoomOptions extends HighlightOptions { viewPadding?: MapPadding; } +/** Options supported by the map model's {@link MapModel.highlightAndZoom | zoom | highlightAndZoom} method. */ +export interface HighlightZoomOptions extends HighlightOptions, ZoomOptions {} + /** * Custom styles when creating a new {@link Highlight}. */ @@ -141,7 +144,7 @@ export interface MapModel extends EventSource { /** * Zooms to the given targets. */ - zoom(geometries: DisplayTarget[], options?: HighlightZoomOptions): void; + zoom(geometries: DisplayTarget[], options?: ZoomOptions): void; /** * Creates a highlight and zooms to the given targets. diff --git a/src/packages/map/model/Highlights.ts b/src/packages/map/model/Highlights.ts index 9e9623e5..a50d40d0 100644 --- a/src/packages/map/model/Highlights.ts +++ b/src/packages/map/model/Highlights.ts @@ -15,7 +15,8 @@ import { Highlight, HighlightOptions, HighlightStyle, - HighlightZoomOptions + HighlightZoomOptions, + ZoomOptions } from "../api/MapModel"; import mapMarkerUrl from "../assets/images/mapMarker.png?url"; import { FeatureLike } from "ol/Feature"; @@ -130,7 +131,7 @@ export class Highlights { /** * This method zoom to geometries or BaseFeatures */ - zoomToHighlight(displayTarget: DisplayTarget[], options: HighlightZoomOptions | undefined) { + zoomToHighlight(displayTarget: DisplayTarget[], options: ZoomOptions | undefined) { const geometries = this.#filterGeoobjects(displayTarget); if (geometries.length === 0) { diff --git a/src/packages/result-list/ResultList.test.tsx b/src/packages/result-list/ResultList.test.tsx index fc85f1cd..8b0c445a 100644 --- a/src/packages/result-list/ResultList.test.tsx +++ b/src/packages/result-list/ResultList.test.tsx @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer) // SPDX-License-Identifier: Apache-2.0 -import { BaseFeature, HighlightZoomOptions } from "@open-pioneer/map"; +import { BaseFeature, ZoomOptions } from "@open-pioneer/map"; import { PackageContextProvider } from "@open-pioneer/test-utils/react"; import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"; import { Mock, SpyInstance, afterEach, beforeEach, expect, it, vi } from "vitest"; @@ -428,7 +428,7 @@ it("should not zoom the map further than the configured maxZoom", async () => { const map = await registry.expectMapModel(mapId); - const zoomOptions: HighlightZoomOptions = { maxZoom: 11 }; + const zoomOptions: ZoomOptions = { maxZoom: 11 }; render(