class
FeatureLayer
extends LayerBase
implements IFeatureLayer, IQueryableLayer
Feature layer that queries a remote OGC service (WFS, OGC API Features). Supports pagination, caching, and collection switching.
Constructor
new FeatureLayer(options: FeatureLayerOptions) | Parameter | Type | Description | |
|---|---|---|---|
options | FeatureLayerOptions | required | Feature layer configuration |
FeatureLayerOptions
| Field | Type | Description | |
|---|---|---|---|
id | string | optional | Layer ID |
url | string | optional | Service base URL |
collectionId | string | optional | Feature collection ID |
adapter | IFeatureAdapter | optional | Injected adapter instance |
adapterFactory | (url: string) => IFeatureAdapter | optional | Factory function for creating adapters |
enableCache | boolean | optional | Enable local feature caching |
visible | boolean | optional | Initial visibility Default: true |
opacity | number | optional | Layer opacity (0-1) Default: 1 |
Properties
| Name | Type | Access | Description |
|---|---|---|---|
type | 'feature' | readonly | Layer type discriminant |
renderer | IRenderer | undefined | read/write | Feature renderer for symbology. Set to apply custom symbols to features. |
Methods
getFeatures()
getFeatures(): readonly Feature[] Get cached features.
Returns
readonly Feature[] queryFeatures()
queryFeatures(params: QueryParams): Promise<Feature[]> Remote query with bbox/where/limit.
Returns
Promise<Feature[]> queryExtent()
queryExtent(params?: QueryParams): Promise<Extent> Get bounding extent of results.
Returns
Promise<Extent> getCollections()
getCollections(): readonly FeatureCollectionInfo[] Get available feature collections from service.
Returns
readonly FeatureCollectionInfo[] getCollectionId()
getCollectionId(): string | undefined Get current collection ID.
Returns
string | undefined Example
const layer = new FeatureLayer({
id: 'buildings',
url: 'https://example.com/ogc/api',
collectionId: 'buildings',
});
view.map.add(layer);
const results = await layer.queryFeatures({
geometry: view.getBounds(),
maxResults: 100,
});