Crate staticmap[−][src]
Expand description
StaticMap is a library for rendering images of tile based maps.
StaticMap uses a builder pattern for building maps, lines and markers.
To get started, build a map instance using StaticMapBuilder and find the tool builders in the tools module.
Features:
- Render a map to a PNG image.
- Draw features on a map, such as:
- Lines
- Circles
- PNG icons
Example
use staticmap::{ tools::{Color, LineBuilder}, StaticMapBuilder, Error, }; fn main() -> Result<(), Error> { let mut map = StaticMapBuilder::default() .width(300) .height(400) .padding((10, 0)) .build()?; let lat: &[f64] = &[52.5, 48.9]; let lon: Vec<f64> = vec![13.4, 2.3]; let red = Color::new(true, 255, 0, 0, 255); let line = LineBuilder::default() .lat_coordinates(lat.to_vec()) .lon_coordinates(lon) .width(3.) .simplify(true) .color(red) .build()?; map.add_tool(line); map.save_png("line.png")?; Ok(()) }
Modules
tools | Tools for drawing features onto the map. |
Structs
Bounds | Helper struct for converting to pixels, and to pass information about map bounds to implementors of Tool. |
StaticMap | Main type. Use StaticMapBuilder as an entrypoint. |
StaticMapBuilder | Builder for StaticMap. |
Enums
Error | An enum containing all possible errors when interacting with this library. |
Functions
lat_to_y | Latitude to y coordinate. |
lon_to_x | Longitude to x coordinate. |
x_to_lon | X to longitude coordinate. |
y_to_lat | Y to latitude coordinate. |