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, RawPoint};
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, RawPoint::new(0.0, 0.0)));
31//! points.insert(2, MapPoint::new(2, RawPoint::new(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//! ## Crate features
41//!
42//! - `puffin`: instruments the widget's hot paths with the
43//!   [`puffin`](https://crates.io/crates/puffin) profiler.
44
45#![forbid(unsafe_code)]
46#![warn(missing_docs)]
47
48pub mod map;