Expand description
A map, MapLibre GL style: named sources (vector tiles, GeoJSON) plus an ordered list of
style layers that say how to draw them, with custom layers for anything else. The app
changes the map with set_data, set_paint, set_filter and friends, draws it with
Map::view, and asks what’s under the pointer with Map::query_rendered_features.
let mut map = Map::new();
map.add_source("basemap", MapSource::vector(Source::open(OPENFREEMAP).await?))?;
map.add_source("route", MapSource::geojson(&route_json)?)?;
map.add_layer(StyleLayer::background("bg").color("#101418"))?;
map.add_layer(StyleLayer::line("roads", "basemap").source_layer("transportation").color("#666"))?;
map.add_layer(StyleLayer::line("route", "route").color("#00e5ff"))?;
loop {
let area = term.get_frame().area();
map.load_tiles(&cam, area).await?;
term.draw(|frame| frame.render_widget(map.view(&cam), area))?;
// What's under a spot: braille dots in the map area (2 per column, 4 per row).
for f in map.query_rendered_features(&cam, area, (40.0, 40.0), Some(&["route"])) {
println!("{}", f.title());
}
}Structs§
- GeoJson
Source - A GeoJSON source: features, a spatial index, and clusters when on.
- Kitty
State - The images
Map::kitty_commandshas sent to the terminal: their decoded size and the last frame that used each. - Loaded
- A fetched and decoded tile.
- Map
- A map: sources, style and custom layers, feature state, and how raster layers draw. See the module docs.
- MapView
- Draws a
Mapwith a camera. Make one withMap::view. - Raster
Tiles - A raster source and its decoded tiles.
- Retry
Policy - Retrying tiles that failed to load (timeouts, network or server errors). A tile that doesn’t exist (“no tile here”) is not a failure: it is stored empty at once.
- Tile
Request - A tile a view needs, to load in the background with
TileRequest::loadand hand back withMap::insert_loaded. - Vector
Source - A vector tile source and its loaded tiles.
Enums§
- MapSource
- A source of features for style layers.
- Raster
Mode - How raster layers are drawn.