Skip to content

Commit

Permalink
add end point instead of set, fixes #396
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Jul 4, 2024
1 parent ef609bf commit e3ac955
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/map/ContextMenuContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export function ContextMenuContent({
route: RouteStoreState
onSelect: () => void
}) {

const dispatchAddPoint = function (coordinate: Coordinate) {
if(queryPoints.length == 2 && !queryPoints[1].isInitialized) {
dispatchSetPoint(queryPoints[1], coordinate)
} else {
onSelect()
Dispatcher.dispatch(new AddPoint(queryPoints.length, coordinate, true))
}
}

const dispatchSetPoint = function (point: QueryPoint, coordinate: Coordinate) {
onSelect()
Dispatcher.dispatch(
Expand Down Expand Up @@ -100,7 +110,7 @@ export function ContextMenuContent({
<button
style={{ paddingBottom: '10px' }}
className={styles.entry}
onClick={() => dispatchSetPoint(queryPoints[queryPoints.length - 1], coordinate)}
onClick={() => dispatchAddPoint(coordinate)}
>
<div>
<MarkerComponent size={16} color={QueryStore.getMarkerColor(QueryPointType.To)} />
Expand Down

0 comments on commit e3ac955

Please sign in to comment.