Class: Layer

ol/layer/Layer~Layer


Abstract base class; normally only used for creating subclasses and not instantiated in apps. A visual representation of raster or vector map data. Layers group together those properties that pertain to how the data is to be displayed, irrespective of the source of that data.

Layers are usually added to a map with module:ol/Map#addLayer. Components like module:ol/interaction/Select~Select use unmanaged layers internally. These unmanaged layers are associated with the map using module:ol/layer/Layer~Layer#setMap instead.

A generic change event is fired when the state of the source changes.

Fires:

Methods

getSource(){module:ol/source/Source~Source}

layer/Layer.js, line 128

Get the layer source.

Returns:
The layer source (or null if not yet set).

setMap(map)

layer/Layer.js, line 178

Sets the layer to be rendered on top of other layers on a map. The map will not manage this layer in its layers collection, and the callback in module:ol/Map#forEachLayerAtPixel will receive null as layer. This is useful for temporary layers. To remove an unmanaged layer from the map, use #setMap(null).

To add the layer to a map and have it managed by the map, use module:ol/Map#addLayer instead.

Name Type Description
map module:ol/PluggableMap~PluggableMap

Map.

setSource(source)

layer/Layer.js, line 211

Set the layer source.

Name Type Description
source module:ol/source/Source~Source

The layer source.