Maps
Explore techniques for creating maps in Rust despite limited native tools. Learn to use the vega_lite_3 crate for static map visualization and integrate Rust with JavaScript libraries like leaflet.js to build interactive web maps. Understand how to manipulate geographic data, manage data binding, and render maps as HTML or PDF outputs. This lesson enables you to combine Rust programming with web technologies for effective geographic data storytelling.
We'll cover the following...
Mapping in Rust
Sadly, there are no tools in pure Rust to create maps. There are tools to handle GIS and geography, but nothing is completely devoted to map creation.
Therefore, we only have a few options to choose from, which might be appreciated by those who need to handle geographic data in Rust.
Currently, we have two main options:
- Use what the ecosystem provides, even if it is incomplete and labor intensive.
- Integrate the Rust ecosystem with other tools, such as creating interactive maps with JavaScript to show in a browser.
We’ll show an example of both methods.
Vega_lite_3
The crate vega_lite_3 is devoted to charting data. It is a little bit more complicated than poloto, but it is much more powerful.
The vega_lite_3 crate employs the builder pattern. We can create the default builder with VegaliteBuilder::default() and then add all the information and data to our charts with a method applied to the builder.
We use build()? to get the graph built and ready to ...