Skip to main content

Filter by distance in meters

['distance', geometry] returns the distance in meters between authoritative WGS84 feature geometry and a target. It works in layer filters, source/rendered query filters and paint expressions, following familiar MapLibre syntax.

const target = { type: 'Point', coordinates: [116.4, 39.9] };
map.setFilter('places', ['<', ['distance', target], 1000]);
await map.sqs.flush({ render: true });

Targets support Point/MultiPoint, LineString/MultiLineString, Polygon/MultiPolygon, Feature/FeatureCollection and GeometryCollection. The sphere radius is6371008.8 meters. Point distances use short arcs; point/line distances minimize great-circle projection and endpoints; intersecting line arcs return zero. Date-line coordinates are handled continuously. Antipodal segment endpoints are ambiguous and reject.

Polygon containment and holes use within's unwrapped longitude/latitude planar topology. Contained geometry has zero distance; other distances use spherical short arcs. This is neither ellipsoid measurement nor complete spherical polygon topology. Use the GIS engine for strict measurement/analysis. Target polygons inherit within's narrow-span, closed-ring and valid-topology constraints.

Source and target each allow2048 coordinates,256 collection entries and8 levels, with8192 evaluation comparisons. Exceeding a budget fails explicitly. The authoritative WGS84 geometry context from08.30 is required. Missing geometry or legacy projected data reports unavailable; direct Rust callers provide geometry as described in spatial-within.

Syntax references the public MapLibre distance specification, independently implemented by SqsMap. Raw SDK callers use view.flush(). Device and formal-release acceptance remain separate.