From bdcc554aaf5c9aaa9e00683354d03cd465eb6285 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Tue, 9 Jul 2024 23:41:38 +0200 Subject: [PATCH] fix routing controls visibility on edges of the map --- .../components/toolbar/tools/routing/RoutingControls.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts index 52551f07..8137dc1b 100644 --- a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts +++ b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts @@ -1,5 +1,4 @@ import { distance, type Coordinates, TrackPoint, TrackSegment, Track } from "gpx"; -import { original } from "immer"; import { get, writable, type Readable } from "svelte/store"; import mapboxgl from "mapbox-gl"; import { route } from "./Routing"; @@ -214,10 +213,14 @@ export class RoutingControls { toggleAnchorsForZoomLevelAndBounds() { // Show markers only if they are in the current zoom level and bounds this.shownAnchors.splice(0, this.shownAnchors.length); + let southWest = this.map.unproject([0, this.map.getCanvas().height]); + let northEast = this.map.unproject([this.map.getCanvas().width, 0]); + let bounds = new mapboxgl.LngLatBounds(southWest, northEast); + let zoom = this.map.getZoom(); this.anchors.forEach((anchor) => { anchor.inZoom = anchor.point._data.zoom <= zoom; - if (anchor.inZoom && this.map.getBounds().contains(anchor.marker.getLngLat())) { + if (anchor.inZoom && bounds.contains(anchor.marker.getLngLat())) { anchor.marker.addTo(this.map); this.shownAnchors.push(anchor); } else {