Skip to content

Commit

Permalink
add a way to see coordinates on the map by a double tap
Browse files Browse the repository at this point in the history
at the desired point
  • Loading branch information
rand256 committed Jul 21, 2022
1 parent 2e92373 commit d4363cb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/zone/js-modules/vacuum-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export function VacuumMap(canvasElement) {

let redrawCanvas = null;

let lastTap = {x: null, y: null, d: 0};

function probeWebSocket() {
clearTimeout(probeTimeout);
probeTimeout = setTimeout(() => {
Expand Down Expand Up @@ -624,6 +626,14 @@ export function VacuumMap(canvasElement) {
locations = locations.filter(l => !(l instanceof GotoPoint));
if(!takenAction && !options.noGotoPoints) {
locations.push(new GotoPoint(tappedPoint.x, tappedPoint.y));
// show current coordinates in alert message by double tap (but only when allowed to set a new point on the map)
if ((Date.now() - lastTap.d < 5e2) && Math.abs(lastTap.x - tappedX) < 10 && Math.abs(lastTap.y - tappedY) < 10) {
window.alert(JSON.stringify(convertToRealCoords(lastTap)));
lastTap = {x: null, y: null, d: 0};
} else {
lastTap = {x: tappedX, y: tappedY, d: Date.now()};
}

}

redraw();
Expand Down

0 comments on commit d4363cb

Please sign in to comment.