#openstreetmap #osm #map

staticmap

Tile based static map image renderer

7 unstable releases (3 breaking)

0.4.0 May 13, 2021
0.3.2 Apr 28, 2021
0.3.1 Mar 7, 2021
0.2.0 Nov 9, 2020
0.1.1 Sep 30, 2020

#144 in Images

Download history 2/week @ 2021-08-08 13/week @ 2021-08-15 1/week @ 2021-08-22 1/week @ 2021-09-05 5/week @ 2021-09-19 9/week @ 2021-10-03 7/week @ 2021-10-10 5/week @ 2021-10-17 68/week @ 2021-10-31 49/week @ 2021-11-07 10/week @ 2021-11-14 11/week @ 2021-11-21

155 downloads per month

MIT license

460KB
739 lines

docs crate

StaticMap

StaticMap is a library for rendering images of tile based maps.

Features

  • Render a map to a PNG image.
  • Draw features on a map, such as:
    • Lines
    • Circles
    • PNG icons

Documentation

API Documentation.

Examples

See the /examples folder for different examples on how to use the library.

Examples can be run with cargo run --example <example name>.

Results:

Line

line

Circle

circle

Icon

icon


lib.rs:

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][StaticMapBuilder] and find the tool builders in the [tools][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(())
}

Dependencies

~13MB
~325K SLoC