egui_map_view/layers/
mod.rs

1//! Layers for the map view that can handle input, and draw on top of the map view different kinds of data.
2//!
3use egui::{Painter, Response};
4use std::any::Any;
5
6use crate::projection::MapProjection;
7
8/// Drawing layer
9#[cfg(feature = "drawing-layer")]
10pub mod drawing;
11
12/// Text layer
13#[cfg(feature = "text-layer")]
14pub mod text;
15
16/// A trait for map layers.
17pub trait Layer: Any {
18    /// Handles user input for the layer. Returns `true` if the input was handled and should not be
19    /// processed further by the map.
20    fn handle_input(&mut self, response: &Response, projection: &MapProjection) -> bool;
21
22    /// Draws the layer.
23    fn draw(&self, painter: &Painter, projection: &MapProjection);
24
25    /// Gets the layer as a `dyn Any`.
26    fn as_any(&self) -> &dyn Any;
27
28    /// Gets the layer as a mutable `dyn Any`.
29    fn as_any_mut(&mut self) -> &mut dyn Any;
30}