Skip to content

Commit

Permalink
By default, don't keep appending points to the end of a route
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed May 30, 2023
1 parent d098647 commit d760e8e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/geojson": "^7946.0.10",
"comlink": "^4.4.1",
"maplibre-gl": "^2.4.0",
"route-snapper": "^0.1.13",
"route-snapper": "^0.1.14",
"svelte": "^3.54.0"
}
}
11 changes: 10 additions & 1 deletion src/lib/draw/route/RouteControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
// TODO Save this in the route
let avoidDoublingBack = false;
let extendRoute = false;
$: routeTool.setRouteConfig({
avoid_doubling_back: avoidDoublingBack,
extend_route: extendRoute,
});
// TODO Show if shift is held or not
Expand All @@ -28,7 +30,14 @@
</ul>
</CollapsibleCard>

<label>
<label title="Keep clicking to add more points to the end of the route">
<input type="checkbox" bind:checked={extendRoute} />
Add points to end
</label>
<br />
<label
title="Try to make the route avoid using the same streets with multiple waypoints"
>
<input type="checkbox" bind:checked={avoidDoublingBack} />
Avoid doubling back
</label>
Expand Down
11 changes: 9 additions & 2 deletions src/lib/draw/route/route_tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ export class RouteTool {
return;
}

this.inner.setConfig({ avoid_doubling_back: true, area_mode: true });
this.inner.setConfig({
avoid_doubling_back: true,
area_mode: true,
extend_route: false,
});
this.active = true;
this.map.boxZoom.disable();
this.map.doubleClickZoom.disable();
Expand Down Expand Up @@ -329,7 +333,10 @@ export class RouteTool {
this.finish();
}

setRouteConfig(config: { avoid_doubling_back: boolean }) {
setRouteConfig(config: {
avoid_doubling_back: boolean;
extend_route: boolean;
}) {
this.inner.setConfig({ ...config, area_mode: false });
this.redraw();
}
Expand Down

0 comments on commit d760e8e

Please sign in to comment.