Queries
Find features by layer, id, properties, location, layer type or source; strict and lazy like a Locator.
import type { FeatureQuery } from 'geowright';const queries: FeatureQuery[] = [ { layer: 'alerts' },// string or string[] { layer: 'alerts', id: 7 }, { layer: 'alerts', where: { severity: 'high' } },// equality { layer: 'alerts', where: { name: /^gas/i } },// RegExp { layer: 'alerts', where: { severity: { in: ['high', 'medium'] }, id: { gte: 2 } } }, // operators: eq ne gt gte lt lte in matches exists { layer: 'td-point', at: { lng: 34.85, lat: 32.04 } },// only what is rendered under that location { layer: 'sensors', visible: 'any' },// default is visible only; 'any' = MapLibre's "rendered" (see below) { layerType: 'circle', where: { cluster: true } },// for layer ids generated by a wrapper (svmlgl-layer-0) { source: 'earthquakes', layerType: ['circle', 'symbol'] },];map.feature(q) is strict (exactly one match, like a Locator); map.features(q) is a set.
Handles are lazy: nothing is resolved until an action or assertion runs.
id is the id in the app's data. MapLibre keeps a feature id only if it is a non-negative integer and draws any other
('north-gate', a UUID, -5, 1.5) as some other number, or none: on a GeoJSON source such an id is found through the source's
data (look-alikes drawn with one number are told apart by where they are drawn); on a tiled source it can never match,
and the query is an error that points to promoteId. A where operand of the wrong kind (in that is not an array,
exists that is not a boolean, a bound that is not a number, an undefined value) is an error too.