Verschiebemodus eingebaut
This commit is contained in:
@@ -788,6 +788,71 @@ describe("MapView marine feature information", () => {
|
||||
);
|
||||
expect(maplibreState.markerConstructions).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps the GPS position centered while navigation follow mode is active", async () => {
|
||||
const onFollowPositionChange = vi.fn();
|
||||
const onMapReady = vi.fn();
|
||||
const onPickCoordinate = vi.fn();
|
||||
const view = render(
|
||||
<MapView
|
||||
config={config}
|
||||
position={{ lat: 52, lon: 7 }}
|
||||
accuracyM={5}
|
||||
startPoint={null}
|
||||
destination={null}
|
||||
pickMode={null}
|
||||
route={null}
|
||||
navigationActive
|
||||
followPosition={false}
|
||||
onFollowPositionChange={onFollowPositionChange}
|
||||
onPickCoordinate={onPickCoordinate}
|
||||
onMapReady={onMapReady}
|
||||
/>
|
||||
);
|
||||
await act(async () => maplibreState.current.emit("load"));
|
||||
|
||||
const followButton = screen.getByRole("button", {
|
||||
name: "GPS-Folge-Modus aktivieren"
|
||||
});
|
||||
expect(followButton).toHaveAttribute("aria-pressed", "false");
|
||||
fireEvent.click(followButton);
|
||||
expect(onFollowPositionChange).toHaveBeenCalledWith(true);
|
||||
expect(maplibreState.current.flyTo).toHaveBeenCalledWith({
|
||||
center: [7, 52],
|
||||
zoom: 13,
|
||||
essential: true
|
||||
});
|
||||
|
||||
view.rerender(
|
||||
<MapView
|
||||
config={config}
|
||||
position={{ lat: 52.01, lon: 7.02 }}
|
||||
accuracyM={5}
|
||||
startPoint={null}
|
||||
destination={null}
|
||||
pickMode={null}
|
||||
route={null}
|
||||
navigationActive
|
||||
followPosition
|
||||
onFollowPositionChange={onFollowPositionChange}
|
||||
onPickCoordinate={onPickCoordinate}
|
||||
onMapReady={onMapReady}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByRole("button", { name: "GPS-Folge-Modus beenden" })
|
||||
).toHaveAttribute("aria-pressed", "true");
|
||||
expect(maplibreState.current.easeTo).toHaveBeenLastCalledWith({
|
||||
center: [7.02, 52.01],
|
||||
zoom: 13,
|
||||
duration: 500,
|
||||
essential: true
|
||||
});
|
||||
|
||||
await act(async () => maplibreState.current.emit("dragstart"));
|
||||
expect(onFollowPositionChange).toHaveBeenLastCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("MapView anchor watch", () => {
|
||||
|
||||
Reference in New Issue
Block a user