29 breaking releases

new 0.30.0 Nov 18, 2024
0.28.0 Nov 5, 2024
0.24.0 Jul 6, 2024
0.20.0 Mar 16, 2024
0.6.0 Jul 18, 2023

#24 in Geospatial

Download history 172/week @ 2024-07-30 106/week @ 2024-08-06 28/week @ 2024-08-13 4/week @ 2024-08-20 28/week @ 2024-08-27 30/week @ 2024-09-03 30/week @ 2024-09-10 29/week @ 2024-09-17 79/week @ 2024-09-24 85/week @ 2024-10-01 318/week @ 2024-10-08 171/week @ 2024-10-15 648/week @ 2024-10-22 2299/week @ 2024-10-29 2522/week @ 2024-11-05 2292/week @ 2024-11-12

7,794 downloads per month
Used in 4 crates (via re_space_view_map)

MIT license

82KB
1.5K SLoC

Walkers, a map widget for Rust

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.

Before deploying your application, please get yourself familiar with the OpenStreetMap usage policy, and consider donating 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};
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,
                Position::from_lon_lat(17.03664, 51.09916)
            ));
        });
    }
}

You can see a more complete example here.

Running demos

Walkers suports numerous build options, such as Android and WASM. They all share a common library - demo, but require a different build workflow, not necessarily compatible with Cargo alone.

Native

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

cd demo_native
cargo run

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

Dependencies

~16–30MB
~466K SLoC