Draw routes in MapLibre snapped to a street network using client-side routing

Overview

MapLibre route snapper

NPM

This plugin lets you draw routes in MapLibre GL that snap to some network (streets, usually). Unlike similar plugins that send a request to a remote API for routing, this one does the routing client-side. This works by loading a pre-built file covering a fixed area and calculating the routes locally.

Demo

Demo

Usage

See the user guide for full details and examples.

  1. Build a graph file covering some fixed area
  2. npm install route-snapper
  3. Construct the RouteSnapper object, passing in the graph file a MapLibre map
  4. Listen to events to use the drawn routes

Development

route-snapper is written in Rust, compiled to WASM to run in the browser, and has a simple Javascript wrapper library. You need wasm-pack and Python (to run a local server).

cd examples
./serve_locally.sh

Contributing

There are many ideas for improving this plugin, such as customizing the instructions, controls, and route style, and generating graph files on-the-fly from vector tile data. Check out the issues or start your own.

This project follows the Rust code of conduct and is Apache 2.0 licensed.

Related work

This tool started life in fall 2021 through Ungap the Map, for sketching potential cycle lanes along existing roads. It used a custom UI and map rendering library built on top of OpenGL. A year later, the idea was adapted to work in ATIP, using MapLibre GL. The functionality for dragging waypoints is partly inspired by Felt, Google Maps, and similar products. To my knowledge, this is the first one with client-side routing.

Comments
  • Jittery snapping sometimes

    Jittery snapping sometimes

    https://user-images.githubusercontent.com/1664407/211030226-f2c855b0-cb55-461a-bf98-4e990ac52162.mov

    Repro near the Lea bridge in Hackney: https://acteng.github.io/atip/scheme.html?authority=Hackney#18.6/51.5620442/-0.0459354 I've hit this elsewhere too.

    Ideas: visualize the circle around the cursor, and the circles we snap to. Make sure we're not snapping so eagerly when zoomed in like this?

    opened by dabreegster 2
  • Offline routing engine

    Offline routing engine

    I'm passively looking into a solution for my need for an offline routing engine. My research can be read here: https://github.com/IsraelHikingMap/Site/issues/1636 Generally speaking the following are my requirements:

    1. I should be able to run this routing engine in Android and iOS, or using Ionic capacitor/webview (pure javascript/WASM)
    2. This routing engine should allow profiles, my use case is: Hike, Bike, 4 wheel drive profiles
    3. The results from the routing engine should have elevation data
    4. The setup time should be minimal - preferably using a pre-process step where the data is saved in a format the routing engine can read fast
    5. [Optional] If the routing engine can receive RGB Terrain tiles and MVT tiles and create a route using this input the need for a dedicated file might not be necessary as I have this data available offline/in memory/cached.
    6. [Optional] Allow running this on a server using a docker container to allow similar results when doing the routing while offline and while online

    My current setup: We are maintaining a docker image of GraphHopper here: https://github.com/IsraelHikingMap/graphhopper-docker-image-push This image can do two things mainly:

    1. Download an OSM pbf file and create a directory, this directory has the graph data in a format graphhopper can read fast
    2. Serve a routing endpoint on the server

    What we do is basically run every hour a build of the graph directory and restart a container to use the newly created graph directory (there is another container that runs in parallel to avoid a time where this service is unavailable).

    I thinks this concept is a solid one - you pre-process the data without affecting anyone, once the data is processed you can read it fast and use it fast for the routing engine. If such a directory/file can be made available to download and use on the client device (using fetch, or a native file transfer) it would be great.

    I'll be happy to help although I have little to no knowledge in Rust, but after using my app in a two days hike where I needed this offline routing feature I've matured to the point where this is probably the next thing for me to invest in.

    As a side note, there's a format I read somewhere called openLR which might be interesting to look into for this package: https://github.com/itinero/OpenLR

    This what I can see as a full implementation, having said that, it might be good to start with a "poor man's routing" where things just snap to a route while you are offline (some kind of fallback) and later on make it better, or not. I have the same concept when it comes to search where the search in the backend is using elasticsearch and when offline I use minisearch.

    Main project in Github: https://github.com/IsraelHikingMap/Site Website: https://israelhiking.osm.org.il/

    opened by HarelM 3
  • Build from something closer to raw OSM

    Build from something closer to raw OSM

    osm2streets may still filter out private roads, service roads, driveways, etc in ways that don't quite match how people here want to use it. Should we just use the osm_reader::Document, look through ways, and look for highway?

    opened by dabreegster 0
  • Be able to override active and inactive control style

    Be able to override active and inactive control style

    Already doing horrible CSS things to override stuff in ATIP. It'd be simpler to optionally have a callback that constructs the DOM elements for both states?

    opened by dabreegster 0
  • Consider terra-draw for the frontend

    Consider terra-draw for the frontend

    Most of the logic of this plugin is in the frontend half, not the routing. Why limit it to MapLibre? https://github.com/JamesLMilner/terra-draw is much more solid foundation to build on

    future 
    opened by dabreegster 0
Owner
Dustin Carlino
Speculative cartographer
Dustin Carlino
High-level networking library that extends the bevy_replicon library to allow snapshot interpolation and client-side prediction

bevy_replicon_snap A Snapshot Interpolation plugin for the networking solution bevy_replicon in the Bevy game engine. This library is a very rough pro

Ben 3 Oct 15, 2023
Cross-chain bridge message delivery network. We are hiring, [email protected]

Introduction Implementation of a https://darwinia.network node in Rust based on the Substrate framework. This repository contains runtimes for the Dar

Darwinia Network 225 Nov 8, 2022
ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot network.

ARYA Network ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot n

Pankaj Chaudhary 6 Dec 20, 2022
The Zenotta Network Protocol (ZNP), the network that supports the Zenotta blockchain

Zenotta Network Protocol A repo for the development of the Zenotta Network Protocol (ZNP). We will regularly be updating links and easter eggs inside

Zenotta AG 10 Apr 2, 2023
dWallet Network, a composable modular signature network is the home of dWallets

Welcome to dWallet Network dWallet Network, a composable modular signature network is the home of dWallets. A dWallet is a noncollusive and massively

dWallet Labs 8 Feb 26, 2024
Extremely low-latency chain data to Stackers, with a dose of mild humour on the side

Ronin Hello there! Ronin is a ultra-speed Stacks API server. It's super lightweight, but scales easily. Why are we making this? Because we don't like

Syvita Guild 11 Mar 29, 2022
🦀 Hop server side SDK for Rust

hop-rs (wip) Hop's Rust library. Requires Rust 1.61+ Installation [dependencies] hop = "0.0.0" Usage Create a project token or personal access token.

Tom 17 Jan 31, 2023
Low-level Bitcoin P2P Network Client

Peerlink What is Peerlink? Peerlink is a low-level network client for the Bitcoin P2P network written in Rust. It uses a nonblocking reactor to accept

Alfred Hodler 6 Dec 23, 2022
Reference library that implements all the necessary functionality for developing a client that is compatible with TAPLE's DLT network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Core TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomous)

Open Canarias 6 Jan 25, 2023
An experimental fork of a16z's Helios Ethereum client which can run its network traffic over the Nym mixnet

Helios (Nym mixnet fork) Helios is a fully trustless, efficient, and portable Ethereum light client written in Rust. This fork of Helios includes nasc

Nym 4 Mar 3, 2023
Nym provides strong network-level privacy against sophisticated end-to-end attackers, and anonymous transactions using blinded, re-randomizable, decentralized credentials.

The Nym Privacy Platform The platform is composed of multiple Rust crates. Top-level executable binary crates include: nym-mixnode - shuffles Sphinx p

Nym 653 Dec 26, 2022
Rust library for practical time-lock encryption using `drand` threshold network

tlock-rs: Practical Timelock Encryption/Decryption in Rust This repo contains pure Rust implementation of drand/tlock scheme. It provides time-based e

Timofey 32 Jan 8, 2023
A CLI Twitter client using kuon

petit A TUI Twitter client using kuon Install Use cargo $ cargo install petit How to use # Login for twitter $ petit login # Tweet $ petit tweet "Thi

uzimaru0000 11 Jan 12, 2022
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Diem 16.7k Jan 8, 2023
The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.

Nervos CKB - The Common Knowledge Base master develop About CKB CKB is the layer 1 of Nervos Network, a public/permissionless blockchain. CKB uses Pro

Nervos Network 1k Dec 30, 2022
The Phala Network Blockchain, pRuntime and the bridge.

Phala Blockchain Phala Network is a TEE-Blockchain hybrid architecture implementing Confidential Contract. This repo includes: node/: the main blockch

Phala Network 314 Jan 6, 2023
A distributed, cryptographically-verifiable blog / social network

FeoBlog FeoBlog is a distributed blogging platform. It takes a lot of its inspiration from Mastodon and Scuttlebutt. It aims to solve a couple of prob

Cody Casterline 71 Dec 11, 2022
Employ your built-in wetware pattern recognition and signal processing facilities to understand your network traffic

Nethoscope Employ your built-in wetware pattern recognition and signal processing facilities to understand your network traffic. Check video on how it

Vesa Vilhonen 86 Dec 5, 2022
A value transfer bridge between the Monero blockchain and the Secret Network.

Secret-Monero-Bridge A value transfer bridge between the Monero blockchain and the Secret Network. Proof-of-Concept Video Demonstration: https://ipfs.

null 28 Dec 7, 2022