Class: 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.



layer/Layer.js, line 128

Get the layer source.

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


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



layer/Layer.js, line 209

Set the layer source.

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

The layer source.