Skip to main content

egui_map/
lib.rs

1//! # egui-map
2//!
3//! An [`egui`](https://docs.rs/egui) widget that renders an interactive 2D map
4//! on screen.
5//!
6//! The [`map::Map`] widget displays a set of nodes connected by lines, with
7//! support for:
8//!
9//! - Panning (click and drag) and zooming (mouse wheel; hold `Ctrl` — or `Cmd`
10//!   on macOS — to zoom faster).
11//! - Spatial indexing of nodes through a kd-tree, so only the nodes inside the
12//!   current viewport are painted each frame.
13//! - Node names and free-floating text labels with configurable visibility
14//!   rules (see [`map::objects::VisibilitySetting`]).
15//! - Pulsing notifications and blinking markers attached to nodes.
16//! - Custom node rendering and right-click context menus through the
17//!   [`map::objects::NodeTemplate`] and [`map::objects::ContextMenuManager`]
18//!   traits.
19//! - Independent light and dark themes (see [`map::objects::MapSettings`]).
20//!
21//! ## Quick start
22//!
23//! ```no_run
24//! use egui_map::map::Map;
25//! use egui_map::map::objects::MapPoint;
26//! use std::collections::HashMap;
27//!
28//! // Build the node set, keyed by node id.
29//! let mut points: HashMap<usize, MapPoint> = HashMap::new();
30//! points.insert(1, MapPoint::new(1, [0.0, 0.0]));
31//! points.insert(2, MapPoint::new(2, [100.0, 50.0]));
32//!
33//! let mut map = Map::new();
34//! map.add_hashmap_points(points);
35//!
36//! // Then, on every frame of your egui update loop:
37//! // ui.add(&mut map);
38//! ```
39//!
40//! ## Profiling
41//!
42//! The widget's hot paths (rendering, viewport culling, point/line loading)
43//! are instrumented with [`profiling`](https://docs.rs/profiling) scopes.
44//! These are no-ops unless the final binary enables one of `profiling`'s
45//! backend features (e.g. `profile-with-tracy`); this crate never needs a
46//! feature of its own for that — enabling the backend feature anywhere in
47//! the dependency graph activates it here too, because `profiling` is a
48//! normal, unconditional dependency.
49
50#![forbid(unsafe_code)]
51#![warn(missing_docs)]
52
53pub mod map;