GithubHelp home page GithubHelp logo

noktoborus / walkers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from podusowski/walkers

0.0 0.0 1.0 10.33 MB

slippy map (openstreetmap) widget for egui

License: MIT License

Rust 98.05% HTML 1.25% Makefile 0.45% Java 0.25%

walkers's Introduction

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

walkers's People

Contributors

podusowski avatar noktoborus avatar koffeinflummi avatar nikitamuraviev10 avatar santiagoalvarez avatar dependabot[bot] avatar samantatarun avatar

Forkers

rustworks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.