Crate mapboxgl

Source
Expand description

mapbox-gl-rs

Unofficial Rust binding for mapbox-gl-js

Crates.io Docs.rs GithubActions

§What’s this?

mapbox-gl-js is an open source library for rendering a beautiful vector-based maps in web browser, built with Mapbox and OSS community. The goal of this project is to create a rust binding for mapbox-gl-js via WebAssembly so that Rustacean can build webapps with beautiful Mapbox maps only in Rust.

NOTE: mapbox-gl-rs is in super-duper infant stage. Most of the features are WIP. Please bear with that if you’re interested! Also, any contributions e.g. bug reports, feature requests, sending a patch are appreciated.

§How does it work?

wasm-bindgen provides a Rust library and tool to compile Rust code into WebAssembly, which allows Rust based application e.g. egui and RustPython to run on web browsers. Most of the people don’t know that wasm-bindgen also allows to invoke JavaScript code from Rust. This project leverages this feature to provide a Rust binding for mapbox-gl-js.

§Usage

Add mapboxgl to your Cargo.toml

mapboxgl = "0.6"

Add the following CSS and JavaScript snippet in html, so that mapboxgl JavaScript module is loaded.

<link href='https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.css' rel='stylesheet' />
<script src="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js"></script>

Build and run your app. If you are a Yew user, the following command will build and start a web server automatically

trunk serve

§Supported features

§Examples

§License

This project is licensed under the MIT license.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use handler::BoxZoomHandler;
pub use image::Image;
pub use image::ImageOptions;
pub use layer::BackgroundLayer;
pub use layer::CustomLayer;
pub use layer::Expression;
pub use layer::FillLayer;
pub use layer::Visibility;
pub use marker::Marker;
pub use marker::MarkerEventListener;
pub use marker::MarkerOptions;
pub use popup::Popup;
pub use popup::PopupOptions;
pub use source::GeoJsonSource;
pub use style::Source;
pub use style::Style;
pub use style::StyleOptions;
pub use style::StyleOrRef;

Modules§

error
event
handler
image
layer
marker
popup
source
style

Structs§

AnimationOptions
CallbackId
ID for a callback.
CameraAnimationOptions
CameraOptions
Handle
LngLat
LngLatBounds
Map
MapListenerId
ID for an event listener.
MapOptions
MarkerId
ID for a marker.
PaddingOptions
QueryFeatureOptions

Enums§

CustomAttribution

Traits§

MapEventListener