use egui_map::map::Map;
use egui_map::map::objects::{ MapPoint, MapSegment};
fn main() -> eframe::Result<()> {
let mut points = Vec::new();
for (id, name, x, y) in [
(1, "Alpha", 0.0, 0.0),
(2, "Beta", 100.0, 50.0),
(3, "Gamma", 50.0, -80.0),
] {
let mut point = MapPoint::new(id, [x, y]);
point.set_name(name.to_string());
points.push(point);
}
for (line_id, endpoints) in [((1, 2), [1, 2]), ((1, 3), [1, 3])] {
for id in endpoints {
points.get_mut(id).unwrap().connections.push(line_id);
}
}
let mut map = Map::new();
map.add_points(points);
let seg1 = MapSegment::new((1, 2), [0.0, 0.0], [100.0, 50.0]);
let seg2 = MapSegment::new((1, 3), [0.0, 0.0], [50.0, -80.0]);
map.add_lines(vec![seg1, seg2]);
eframe::run_ui_native(
"egui-map: basic",
eframe::NativeOptions::default(),
move |ui, _frame| {
ui.add(&mut map);
},
)
}