Atlaslog
Atlaslog / MapLibre GL JS / API / querySourceFeatures
MapLibre GL JS · API reference

querySourceFeatures

Quick answer

querySourceFeatures ( sourceId : string , parameters? : QuerySourceFeatureOptions ): GeoJSONFeature []

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Runnable examplesChinese noteAll API topics
querySourceFeatures()

querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions): GeoJSONFeature[]

Defined in: ui/map.ts:2658

Returns an array of MapGeoJSONFeature objects representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.

Parameters

Parameter Type Description
sourceId string The ID of the vector tile or GeoJSON source to query.
parameters? QuerySourceFeatureOptions The options object.

Returns

GeoJSONFeature[]

An array of MapGeoJSONFeature objects.

In contrast to Map.queryRenderedFeatures, this function returns all features matching the query parameters, whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently visible viewport.

Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.

Example

Find all features in one source layer in a vector source

let features = map.querySourceFeatures('your-source-id', {
  sourceLayer: 'your-source-layer'
});


TutorialsAPI index
English reference text adapted from the official MapLibre GL JS documentation, © MapLibre contributors, licensed under BSD-3-Clause.
Original page: https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/ · Chinese note: /maplibre/api/query-source-features.html
Cite this page

Atlaslog (2026). querySourceFeatures. https://www.jingweizhi.com/en/maplibre/api/query-source-features.html (accessed 2026-11-03).