-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add range and marker to Directions tool #215
Conversation
This adds a UI control to direction options to allow input of a range as a positive integer. When a range value exists, the route planner now captures the point along the route where the range limit is met. The directions tool now shows a new marker at the range limit point.
Looks good overall. I like how modifying range updates the range marker without needing to run the route again. Marker dropshadow looks nice on the side it is on, but the marker white border doesn't have great contrast against the (current) light coloured basemap elsewhere. |
if (option.rangeKm > 0 && data.distance && option.rangeKm < data.distance) { | ||
var distanceKm = 0; | ||
for (var i = 0; i < data.route.length + 1; i += 1) { | ||
distanceKm += turf.distance(data.route[i], data.route[i+1], {units: "kilometers"}); | ||
if (distanceKm >= option.rangeKm) { | ||
data.rangeLimit = data.route[i]; | ||
break; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like. Seems like performance is fair (~2 s), even for long routes with longer ranges (750 km)
@@ -8,6 +8,8 @@ | |||
<template slot="commands"> | |||
</template> | |||
|
|||
<enter-input v-bind:value="rangeKm" v-on:change="!busy && $$emit('change', {rangeKm: $event});">Range (km)</enter-input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had talked about a slider before, but entering a numerical value is quick and easy to be precise. Though slider would maybe be preferable on mobile.
This adds a UI control to direction options to allow input of a range as a positive integer. When a range value exists, the route planner now captures the point along the route where the range limit is met. The directions tool shows a new marker at the range limit point.