Skip to main content

Vector tile query deduplication

Stable identity, result order and fragment geometry

queryRenderedFeatures deduplicates matching vector features with stable IDs within each displayed layer. Numeric 1 and string '1' are distinct; features without IDs remain separate. Use promoteId to derive IDs from tile properties.

Visibility, filters and actual geometry intersection run before deduplication. The last drawn matching fragment wins. Different displayed layers retain separate results, including state, sourceLayer, source instance and data revision.

Returned geometry is a matching tile fragment, not necessarily the complete region or line. querySourceFeatures preserves every loaded fragment and may contain duplicates. This stage does not merge geometry or clip tile buffers.

const hits = await map.queryRenderedFeatures([200, 140], {
  layers: ['places'],
  filter: ['==', ['id'], 1]
});

Queries scan at most 100,000 displayed records and return at most 1,000 results / 8 MiB. Limits fail explicitly; reduce the region or selected layers. Native persistent QuickJS, browser main thread and strict Worker use the same implementation. One-shot scripts cannot await loading events: the host must prepare resources. Mobile devices and external platforms remain pending.

The complete HTML example includes four generated tiles, all controls and source attribution.