mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 16:52:31 +00:00
fix routing controls update for multiple segments
This commit is contained in:
@@ -52,6 +52,7 @@ export class RoutingControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateControls() { // Update the markers when the file changes
|
updateControls() { // Update the markers when the file changes
|
||||||
|
let anchorIndex = 0;
|
||||||
for (let segment of get(this.file).getSegments()) {
|
for (let segment of get(this.file).getSegments()) {
|
||||||
if (segment.trkpt.length === 0) { // Empty segment, skip
|
if (segment.trkpt.length === 0) { // Empty segment, skip
|
||||||
continue;
|
continue;
|
||||||
@@ -71,7 +72,6 @@ export class RoutingControls {
|
|||||||
segment.trkpt[segment.trkpt.length - 1]._data.zoom = 0;
|
segment.trkpt[segment.trkpt.length - 1]._data.zoom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let anchorIndex = 0;
|
|
||||||
for (let point of segment.trkpt) { // Update the existing anchors (could be improved by matching the existing anchors with the new ones?)
|
for (let point of segment.trkpt) { // Update the existing anchors (could be improved by matching the existing anchors with the new ones?)
|
||||||
if (point._data.anchor) {
|
if (point._data.anchor) {
|
||||||
if (anchorIndex < this.anchors.length) {
|
if (anchorIndex < this.anchors.length) {
|
||||||
@@ -84,11 +84,11 @@ export class RoutingControls {
|
|||||||
anchorIndex++;
|
anchorIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (anchorIndex < this.anchors.length) { // Remove the extra anchors
|
while (anchorIndex < this.anchors.length) { // Remove the extra anchors
|
||||||
this.anchors.pop()?.marker.remove();
|
this.anchors.pop()?.marker.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.toggleAnchorsForZoomLevelAndBounds();
|
this.toggleAnchorsForZoomLevelAndBounds();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user