Skip to main content

slint_mapping/
lib.rs

1//! slint-mapping — a map framework for Slint.
2//!
3//! Minimal usage (offline raster tiles from a slippy-map directory):
4//!
5//! ```ignore
6//! use slint::ComponentHandle;
7//! use slint_mapping::{MapView, MapController, sources::FileTileSource};
8//!
9//! let map = MapView::new()?;
10//! let _controller = MapController::new(
11//!     &map,
12//!     FileTileSource::new("/data/osm-tiles").with_extension("png"),
13//! );
14//! map.show()?;
15//! slint::run_event_loop()?;
16//! ```
17//!
18//! ## Adapters
19//!
20//! Tile sources are pluggable: implement [`TileSource`] for any
21//! backing store (filesystem, MBTiles, in-memory generator, HTTP cache,
22//! …). [`sources::FileTileSource`] is the only adapter that ships
23//! today.
24//!
25//! ## Status
26//!
27//! v0.x. Pan + scroll-zoom work; pinch-zoom waits on Slint exposing
28//! multi-pointer touch events. No marker / polyline overlays yet.
29
30slint::include_modules!();
31
32pub mod cache;
33pub mod camera;
34pub mod controller;
35pub mod projection;
36pub mod source;
37pub mod sources;
38pub mod viewport;
39
40#[cfg(feature = "http")]
41pub mod prefetch;
42
43#[cfg(feature = "routing")]
44pub mod routers;
45#[cfg(feature = "routing")]
46pub mod routing;
47
48pub use cache::{CacheError, FileTileCache, LayeredTileCache, TileCache};
49pub use controller::MapController;
50pub use source::{TileKey, TileSource};
51
52#[cfg(feature = "routing")]
53pub use routing::{Maneuver, ManeuverKind, Profile, Route, RouteError, RouteRequest, Router};
54
55/// Filesystem path to this crate's `ui/` directory — the entry point
56/// Slint resolves `@mapping/...` library_paths imports against. Pass
57/// this (wrapped in a `PathBuf`) to
58/// `slint_build::CompilerConfiguration::with_library_paths` from a
59/// consuming crate's `build.rs` and you can write
60/// `import { MapEmbed } from "@mapping/map.slint";` in your `.slint`
61/// files.
62pub const UI_LIBRARY_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/ui");
63
64/// Filesystem path to this crate's bundled `sample-tiles/` directory.
65/// Suitable for feeding into [`sources::FileTileSource`] for demos
66/// without external assets; covers zoom levels 0–3 (the whole world,
67/// 85 tiles, ~450 KB).
68pub const SAMPLE_TILES_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/sample-tiles");