mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
fix routing controls visibility on edges of the map
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user