Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dabreegster/route_snapper
Draw routes in MapLibre snapped to a street network using client-side routing
https://github.com/dabreegster/route_snapper
Last synced: 7 days ago
JSON representation
Draw routes in MapLibre snapped to a street network using client-side routing
- Host: GitHub
- URL: https://github.com/dabreegster/route_snapper
- Owner: dabreegster
- License: apache-2.0
- Created: 2022-12-23T14:19:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T14:57:30.000Z (16 days ago)
- Last Synced: 2024-10-23T17:20:46.179Z (16 days ago)
- Language: Rust
- Homepage: https://dabreegster.github.io/route_snapper
- Size: 7.98 MB
- Stars: 137
- Watchers: 8
- Forks: 9
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
- awesome-maplibre - route-snapper - Draw routes and areas snapped to roads. (User Interface Plugins / JavaScript)
README
# MapLibre route snapper
[![NPM](https://img.shields.io/npm/v/route-snapper)](https://www.npmjs.com/package/route-snapper)
This plugin lets you draw routes and polygon areas 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](https://dabreegster.github.io/route_snapper)
![Demo](demo.gif)
## Usage
See the [user guide](user_guide.md) 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](https://rustwasm.github.io/wasm-pack/installer/) 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](https://github.com/dabreegster/route_snapper/issues) or start your own.
This project follows the [Rust code of conduct](https://www.rust-lang.org/policies/code-of-conduct) and is Apache 2.0 licensed.
## Related work
This tool started life in fall 2021 through [Ungap the Map](https://a-b-street.github.io/docs/software/ungap_the_map/index.html), 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](https://github.com/acteng/atip), using MapLibre GL. The functionality for dragging waypoints is partly inspired by [Felt](https://felt.com), Google Maps, and similar products.
Other projects with client-side routing: [ngraph.path](https://github.com/anvaka/ngraph.path.demo), [geojson-path-finder](https://github.com/perliedman/geojson-path-finder)