meshmonitor icon indicating copy to clipboard operation
meshmonitor copied to clipboard

[FEAT] distance measurement tool from node to node

Open kokoshell opened this issue 5 months ago • 1 comments

Hi Yeraze, Is it possible to add a LOS distance measurement tool from node to node for both Meshtastic and Meshcore maps ?

Thank you ! Kokoshell

kokoshell avatar Jun 22 '26 07:06 kokoshell

Hi @kokoshell — great suggestion! This is well-aligned with MeshMonitor's map features, and the good news is the codebase already has a Haversine distance utility (src/utils/distance.ts) ready to power it. Here's the implementation plan I'm proposing:


Plan: Node-to-Node Distance Measurement Tool

Overview

Add a toggleable Measure Distance mode to the Meshtastic and MeshCore maps. When active, the user clicks two nodes (or map points) and a line is drawn between them with the straight-line (LOS) distance displayed as a label.

User Flow

  1. User clicks a "Measure Distance" ruler icon button in the map toolbar to enter measurement mode.
  2. User clicks the first node → it gets a highlighted ring marker and is pinned as the origin.
  3. User clicks the second node → a dashed polyline is drawn between the two nodes, with the LOS distance shown as a floating label at the midpoint.
  4. Clicking the toolbar button again (or pressing Escape) clears the measurement and exits mode.

Files to Change

File Change
src/utils/distance.ts Already has calculateDistance() + formatDistance() — no changes needed
src/components/Dashboard/DashboardMap.tsx Add measurement mode state, toolbar button, click handler on node markers, <Polyline> + <Tooltip> for the measurement line
src/components/MeshCore/MeshCoreMap.tsx Same treatment for the MeshCore map
src/components/MapAnalysis/MapAnalysisCanvas.tsx Add a MeasureDistanceLayer to the Map Analysis workspace (optional stretch goal)
src/components/MapAnalysis/layers/MeasureDistanceLayer.tsx New layer component encapsulating the measurement UI (polyline + tooltip + pin markers) for reuse across maps

Implementation Details

  • No backend changes — purely frontend, using GPS coordinates already loaded into the map.
  • Respects the user's existing km/mi distance unit preference via formatDistance().
  • Shows a graceful message ("Node has no position data") if a selected node lacks GPS coordinates.
  • The measurement toolbar button will only be visible when at least 2 nodes with known positions are present.
  • On mobile/touch, the two-tap workflow translates naturally.

Scope

  • Phase 1 (this issue): DashboardMap + MeshCoreMap — both maps get the tool.
  • Phase 2 (optional): MapAnalysisCanvas workspace layer for time-windowed analysis.

I'll hold off on writing code until @Yeraze gives the go-ahead. Let me know if the UX flow or scope should be adjusted!


Generated by Claude Code

Yeraze avatar Jun 22 '26 07:06 Yeraze