Module errors

Module errors 

Source
Expand description

Rust bindings for the Maptiler Cloud API

The Maptiler Cloud API allows for simple access to images that allow people to make simple maps using satellite imagery, contour maps, or street maps.

§Example

#[tokio::main]
async fn main() {
    // Create a new Maptiler Cloud session
    // Use your own API key from Maptiler Cloud
    let maptiler = maptiler_cloud::Maptiler::new("placeholder api key").unwrap();

    // Create a new tile request
    let x = 2;
    let y = 1;
    let zoom = 2;

    let tile_request = maptiler_cloud::TileRequest::new(
        maptiler_cloud::TileSet::Satellite,
        x,
        y,
        zoom
    ).unwrap();

    // Create the request using the Maptiler session
    let constructed = maptiler.create_request(tile_request);

    // Actually perform the request to get the data
    let satellite_jpg = constructed.execute().await.unwrap();

    // Check for JPEG file magic to make sure we got an image
    assert_eq!(&satellite_jpg[0..3], &[0xFF, 0xD8, 0xFF]);
}

From there, most users will write those bytes to a file, or load them into another function that will be able to display the image from the raw JPEG bytes.

Enums§

ArgumentError
This error type represents an error from a request argument that was invalid
Error
This error type wraps other crate’s errors