Crate walkers

Crate walkers 

Source
Expand description

§Walkers, a map widget for Rust

made in Europe crates.io docs.rs

Walkers is a slippy maps widget for egui, similar to very popular Leaflet, but written in Rust. It compiles to native applications as well as WASM. See the online demo here.

Screenshot

It supports OpenStreetMap, mapbox, and compatible tile servers. There is also experimental support for off-line vector tiles using the PMTiles format.

Before deploying your application, please get yourself familiar with the OpenStreetMap usage policy, and consider donating to the OpenStreetMap Foundation.

§Quick start

Walkers has three main objects. Tiles downloads images from a tile map provider such as OpenStreetMap and stores them in a cache, MapMemory keeps track of the widget’s state and Map is the widget itself.

use walkers::{HttpTiles, Map, MapMemory, Position, sources::OpenStreetMap, lon_lat};
use egui::{Context, CentralPanel};
use eframe::{App, Frame};

struct MyApp {
    tiles: HttpTiles,
    map_memory: MapMemory,
}

impl MyApp {
    fn new(egui_ctx: Context) -> Self {
        Self {
            tiles: HttpTiles::new(OpenStreetMap, egui_ctx),
            map_memory: MapMemory::default(),
        }
    }
}

impl App for MyApp {
    fn update(&mut self, ctx: &Context, _frame: &mut Frame) {
        CentralPanel::default().show(ctx, |ui| {
            ui.add(Map::new(
                Some(&mut self.tiles),
                &mut self.map_memory,
                lon_lat(17.03664, 51.09916)
            ));
        });
    }
}

You can see a more complete example here.

§Native

To run demo application locally, use a default cargo run target.

cargo run

To see vector maps support in action, you need to obtain some .pmtiles files and put them into the directory from where you run the demo. One way of doing that is to download an extract from Protonmaps.

pmtiles extract https://build.protomaps.com/20250928.pmtiles --bbox 16.802768,51.036355,17.209205,51.180686 wroclaw.pmtiles

To enable mapbox layers, you need to define MAPBOX_ACCESS_TOKEN environment variable before building. You can get one by creating a mapbox account.

§Web / WASM

cd demo_web
trunk serve --release

§Android

You need to have Android SDK and cargo-ndk installed.

cd demo_android
make run-on-device

Modules§

mercator
Project the lat/lon coordinates into a 2D x/y using the Web Mercator. https://en.wikipedia.org/wiki/Web_Mercator_projection https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames https://www.netzwolf.info/osm/tilebrowser.html?lat=51.157800&lon=6.865500&zoom=14
sources
Some common HTTP tile sources. Make sure you follow terms of usage of the particular source.

Structs§

HeaderValue
Represents an HTTP header field value.
HttpOptions
Controls how crate::HttpTiles use the HTTP protocol, such as caching.
HttpTiles
Downloads the tiles via HTTP. It must persist between frames.
InvalidZoom
LocalTiles
Uses local directory as tile source.
Map
The actual map widget. Instances are to be created on each frame, as all necessary state is stored in Tiles and MapMemory.
MapMemory
State of the map widget which must persist between frames.
MaxParallelDownloads
Maximum number of parallel downloads.
Projector
Projects geographical position into pixels on the viewport, suitable for egui::Painter.
Stats
Style
Dummy style, used when mtv feature is not enabled.
TileId
Identifies the tile in the tile grid.
TilePiece
Clipped piece of a tile.

Enums§

Tile

Traits§

Plugin
Plugins allow drawing custom shapes on the map. After implementing this trait for your type, you can add it to the map with Map::with_plugin
Tiles
Source of tiles to be put together to render the map.

Functions§

lat_lon
Construct Position from latitude and longitude.
lon_lat
Construct Position from longitude and latitude. Note that it is common standard to write coordinates starting with the latitude instead (e.g. 51.104465719934176, 17.075169894118684 is the Wrocław’s zoo).

Type Aliases§

Position
Geographical position with latitude and longitude.