Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/newcomb-luke/maptiler-cloud
Rust wrapper around the Maptiler Cloud API
https://github.com/newcomb-luke/maptiler-cloud
rust rust-crate
Last synced: about 1 month ago
JSON representation
Rust wrapper around the Maptiler Cloud API
- Host: GitHub
- URL: https://github.com/newcomb-luke/maptiler-cloud
- Owner: newcomb-luke
- License: mit
- Created: 2021-10-11T18:37:05.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-25T19:42:11.000Z (about 3 years ago)
- Last Synced: 2024-11-14T18:20:44.050Z (about 2 months ago)
- Topics: rust, rust-crate
- Language: Rust
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maptiler-cloud
Rust wrapper around the [Maptiler Cloud](https://cloud.maptiler.com/maps/) APISupports requesting all currently available tilesets
Tiles are requested using the [Tiled Web Map](https://en.wikipedia.org/wiki/Tiled_web_map) format.
X and Y coordinates are specified, and a zoom level is specified.## Example Usage
```rust
#[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.