Skip to content

Commit

Permalink
Introduce ZoomOptions-type (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophMaskos committed Mar 25, 2024
1 parent 434fd3e commit 520a97b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/pretty-pillows-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@open-pioneer/result-list": minor
"@open-pioneer/map": minor
---

Introduce ZoomOptions-type
11 changes: 7 additions & 4 deletions src/packages/map/api/MapModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ 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.
*/
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).
*/
Expand All @@ -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}.
*/
Expand Down Expand Up @@ -141,7 +144,7 @@ export interface MapModel extends EventSource<MapModelEvents> {
/**
* 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.
Expand Down
5 changes: 3 additions & 2 deletions src/packages/map/model/Highlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/result-list/ResultList.test.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
<PackageContextProvider services={injectedServices} locale="de">
Expand Down

0 comments on commit 520a97b

Please sign in to comment.