Skip to main content

Module drawing

Module drawing 

Source
Expand description

Drawing layer A layer for freeform drawing on the map.

§Example

use eframe::egui;
use egui_map_view::{layers::drawing::DrawingLayer, layers::drawing::DrawMode, Map, config::OpenStreetMapConfig};

struct MyApp {
    map: Map,
}

impl Default for MyApp {
  fn default() -> Self {
    let mut map = Map::new(OpenStreetMapConfig::default());
     map.add_layer("drawing", DrawingLayer::default());
     if let Some(drawing_layer) = map.layer_mut::<DrawingLayer>("drawing") {
       drawing_layer.draw_mode = DrawMode::Draw;
     }
     Self { map }
   }
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.add(&mut self.map);
        });
    }
}

Structs§

DrawingLayer
Layer implementation that allows the user to draw polylines on the map.
Polyline
A polyline on the map.

Enums§

DrawMode
The mode of the DrawingLayer.