Expand description
§egui-map
An egui widget that renders an interactive 2D map
on screen.
The map::Map widget displays a set of nodes connected by lines, with
support for:
- Panning (click and drag) and zooming (mouse wheel; hold
Ctrl— orCmdon macOS — to zoom faster). - Spatial indexing of nodes through a kd-tree, so only the nodes inside the current viewport are painted each frame.
- Node names and free-floating text labels with configurable visibility
rules (see
map::objects::VisibilitySetting). - Pulsing notifications and blinking markers attached to nodes.
- Custom node rendering and right-click context menus through the
map::objects::NodeTemplateandmap::objects::ContextMenuManagertraits. - Built-in color themes with independent light and dark variants, or a
custom palette installed through
map::theme::MapTheme(seemap::objects::MapSettingsfor the rest of the visual style).
§Quick start
use egui_map::map::Map;
use egui_map::map::objects::MapPoint;
use std::collections::HashMap;
// Build the node set, keyed by node id.
let mut points: HashMap<usize, MapPoint> = HashMap::new();
points.insert(1, MapPoint::new(1, [0.0, 0.0]));
points.insert(2, MapPoint::new(2, [100.0, 50.0]));
let mut map = Map::new();
map.add_hashmap_points(points);
// Then, on every frame of your egui update loop:
// ui.add(&mut map);§Profiling
The widget’s hot paths (rendering, viewport culling, point/line loading)
are instrumented with tracing spans. These
are cheap no-ops unless a tracing subscriber is installed somewhere in
the final binary; this crate never needs a feature of its own for that —
a consumer that installs a subscriber (e.g. tracing_tracy::TracyLayer,
for the Tracy profiler) picks up
these spans for free, because tracing is a normal, unconditional
dependency shared across the whole dependency graph.
Modules§
- map
- Interactive map widget and the data types it renders.