Class: STACLayer

ol/layer/STAC~STACLayer


import STACLayer from 'ol/layer/STAC.js';

Renders STAC entities such as STAC Items, Collectons or lists of them as returned by APIs. The layers created by this LayerGroup all have a 'stac' value that can be retrieved using layer.get('stac').

new STACLayer(options)

Name Type Description
url string | undefined

The STAC URL. Any of url and data must be provided. Can also be used as url for data, if it is absolute and doesn't contain a self link.

data STAC | Asset | Object | undefined

The STAC metadata. Any of url and data must be provided. data take precedence over url.

assets Array.<(string|Asset)> | null (defaults to null)

The selector for the assets to be rendered, only for STAC Items and Collections. This can be an array of strings corresponding to asset keys or Asset objects. null shows the default asset, an empty array shows no asset.

bands Array.<number> | undefined

The (one-based) bands to show.

getSourceOptions function | undefined

Optional function that can be used to configure the underlying sources. The function can do any additional work and return the completed options or a promise for the same. The function will be called with the current source options and the STAC Asset or Link. This can be useful for adding auth information such as an API token, either via query parameter or HTTP headers. Please be aware that sending HTTP headers may not be supported by all sources.

displayFootprint boolean (defaults to true)

Allows to hide the footprints (bounding box/geometry) of the STAC object by default.

displayGeoTiffByDefault boolean (defaults to false)

Allow to choose non-cloud-optimized GeoTiffs as default image to show, which might not work well for larger files or larger amounts of files.

displayPreview boolean (defaults to false)

Allow to display images that a browser can display (e.g. PNG, JPEG), usually assets with role thumbnail or the link with relation type preview. The previews are usually not covering the full extents and as such may be placed incorrectly on the map. For performance reasons, it is recommended to enable this option if you pass in STAC API Items.

displayOverview boolean (defaults to true)

Allow to display COGs and, if displayGeoTiffByDefault is enabled, GeoTiffs, usually the assets with role overview or visual.

displayWebMapLink string | boolean | Array.<(module:ol/layer/STAC~Link|string)> (defaults to false)

Allow to display a layer based on the information provided through the web map links extension. If an array of links or link ids (property id in a Link Object) is provided, all corresponding layers will be shown. If set to true or to a specific type of web map link (pmtiles, tilejson, wms, wmts, xyz), it lets this library choose a web map link to show, but only if no other data is shown. To disable the functionality set this to false.

boundsStyle Style | undefined

The style for the overall bounds / footprint.

collectionStyle Style | undefined

The style for individual items in a list of STAC Items or Collections.

crossOrigin null | string | undefined

For thumbnails: The crossOrigin attribute for loaded images / tiles. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

buildTileUrlTemplate function (defaults to null)

A function that generates a URL template for a tile server (XYZ), which will be used instead of the client-side GeoTIFF rendering (except if useTileLayerAsFallback is true).

useTileLayerAsFallback boolean (defaults to false)

Uses the given URL template only when the client-side GeoTIFF rendering fails.

opacity number (defaults to 1)

Opacity (0, 1).

visible boolean (defaults to true)

Visibility.

extent Extent | undefined

The bounding extent for layer rendering. The layer will not be rendered outside of this extent.

zIndex number | undefined

The z-index for layer rendering. At rendering time, the layers will be ordered, first by Z-index and then by position. When undefined, a zIndex of 0 is assumed for layers that are added to the map's layers collection, or Infinity when the layer's setMap() method was used.

minResolution number | undefined

The minimum resolution (inclusive) at which this layer will be visible.

maxResolution number | undefined

The maximum resolution (exclusive) below which this layer will be visible.

minZoom number | undefined

The minimum view zoom level (exclusive) above which this layer will be visible.

maxZoom number | undefined

The maximum view zoom level (inclusive) at which this layer will be visible.

properties Object.<string, *> | undefined

Arbitrary observable properties. Can be accessed with #get() and #set(). stac and bounds are reserved and may be overridden.

Fires:
  • assetsready
  • error
  • sourceready

Methods

addLayerForLink(link){Promise.<(Array.<module:ol/layer/STAC~Layer>|undefined)>}

Adds a layer for a link that implements the web-map-links extension. Supports: PMTiles, TileJSON, WMS, WMTS, XYZ

Name Type Description
link Link

A web map link

See:
Returns:
Resolves with a list of layers or undefined when complete.

getAssets(){Array.<Asset>}

Get the STAC assets shown.

Returns:
The STAC assets.

getBoundsLayer(){VectorLayer | null}

Returns the vector layer that visualizes the bounds / footprint.

Returns:
The vector layer for the bounds

getData(){STAC | Asset}

Get the STAC object.

Returns:
The STAC object.

getExtent(){Extent | undefined}

Get the extent of the layer. If displayFootprint is set to false, the extent is always returned in EPSG:4326 instead of the map projection. Make sure to transform it with the ol.proj.transformExtent function if needed.

Returns:
The layer extent.

getWebMapLinks(){Array<Link>}

Returns all potential web map links based on the given value for displayWebMapLink.

Returns:
An array of links.

hasOnlyBounds(){boolean}

Indicates whether the LayerGroup shows only the bounds layer (i.e. no imagery/tile layers).

Returns:
true if only the bounds layer is shown, false otherwise.

setAssets(assets){Promise}

Update the assets to be rendered.

Name Type Description
assets Array.<(string|Asset)> | null

The assets to show.

Returns:
Resolves when all assets are rendered.