Skip to main content

Filter points and lines within polygons

['within', boundary] works in layer filters, rendered/source query filters and shared paint expressions. boundary is a WGS84 Polygon, MultiPolygon, Feature or FeatureCollection. Evaluation uses actual source geometry, independently of the current map projection.

const boundary = { type: 'Polygon', coordinates: [
  [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]
] };
map.setFilter('points', ['within', boundary]);
await map.sqs.flush({ render: true });
const matches = await map.querySourceFeatures('places', {
  filter: ['within', boundary]
});

Points must be strictly inside: boundaries and holes are excluded. Line endpoints and the entire segment must remain inside one polygon. Touching edges or crossing holes returns false. Every MultiPoint/MultiLineString part must satisfy this rule. Target polygons are checked individually; overlapping polygons are not merged to cover a complete line. Polygon and GeometryCollection features currently return false. Other target geometry types reject.

Narrow date-line boundaries unwrap continuously; each ring must span less than180 degrees and cannot wind around the sphere. Limits are2048 boundary coordinates,256 polygons/rings,8 collection levels and8192 evaluation comparisons. Coordinates must be finite, rings closed and area nonzero. Callers must provide topologically valid input, including freedom from self-intersections.

Rust StyleFeature adds optional WGS84 geometry; direct constructors must update. Missing geometry reports unavailable. Legacy desktop CPU attribute styles support WGS84 sources; projected sources must first convert. Shared named-source/layer hosts retain authoritative WGS84 display geometry. GIS processing and topology repair remain engine responsibilities.

Syntax references the public MapLibre within specification; SqsMap implements it independently. Raw SDK callers use view.flush(). Device and formal-release acceptance remain separate.

Current predicates compute segment/ring topology in the continuously unwrapped longitude/latitude plane, not geodesic geometry or topology repair.