17 breaking releases

0.18.0 Feb 8, 2024
0.16.0 Jan 13, 2024
0.15.0 Dec 25, 2023
0.13.0 Nov 25, 2023
0.6.0 Jul 18, 2023

#65 in Geospatial

Download history 19/week @ 2023-10-26 105/week @ 2023-11-02 48/week @ 2023-11-09 15/week @ 2023-11-16 79/week @ 2023-11-23 65/week @ 2023-11-30 47/week @ 2023-12-07 23/week @ 2023-12-14 67/week @ 2023-12-21 3/week @ 2023-12-28 34/week @ 2024-01-04 73/week @ 2024-01-11 21/week @ 2024-01-18 27/week @ 2024-01-25 21/week @ 2024-02-01 39/week @ 2024-02-08

112 downloads per month

MIT license

67KB
1.5K SLoC

Walkers, a map widget for Rust

crates.io

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::{Tiles, Map, MapMemory, Position, sources::OpenStreetMap};
use egui::{Context, CentralPanel};
use eframe::{App, Frame};

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

impl MyApp {
    fn new(egui_ctx: Context) -> Self {
        Self {
            tiles: Tiles::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

~25–39MB
~491K SLoC