Querying features
Two queries answer “what’s here?”. Both take a target in braille dots relative to the map area (2 per column, 4 per row).
let dot = ((col - area.x) as f64 * 2.0 + 1.0, (row - area.y) as f64 * 4.0 + 2.0);What’s drawn here
Section titled “What’s drawn here”let hits = map.query_rendered_features(&cam, area, dot, None);let pins = map.query_rendered_features(&cam, area, dot, Some(&["pins"]));Like MapLibre’s queryRenderedFeatures: features drawn under the target,
top layer first and, within a layer, points before lines before polygons. Pass
layer ids to search only those. Custom layers answer through their pick.
Everything here
Section titled “Everything here”let all = map.query_features(&cam, area, dot);Every feature of every source under the target, drawn or not: this is what the viewer’s inspect mode shows. Sources come in the order of their topmost layer; within a source, points, then lines, then polygons from smallest to largest. Each result says whether a layer draws it.
Both return Vec<Pick>:
| Field | |
|---|---|
layer |
The source layer ("transportation", "poi", or the GeoJSON source) |
style_layer |
The style or custom layer that draws it, if any |
drawn |
Whether a shown layer draws it |
source |
The map source id |
tile |
The vector tile it came from (None for GeoJSON) |
geom |
Point, line or polygon |
props |
All properties, in order |
lonlat |
Geometry in lon/lat: points, lines or polygon rings |
stats |
Measurements: center, length or area, vertex count |
Helpers: prop("name"), title() (a good one-line name), kind(), and
to_json(), the same JSON that mapterm --pick prints.