Class: FeatureOverlay

ol.FeatureOverlay

A mechanism for changing the style of a small number of features on a temporary basis, for example highlighting. This is necessary with the Canvas renderer, where, unlike in SVG, features cannot be individually referenced. See examples/vector-layers for an example: create a FeatureOverlay with a different style, copy the feature(s) you want rendered in this different style into it, and then remove them again when you're finished.

new ol.FeatureOverlay(opt_options) experimental

src/ol/featureoverlay.js, line 30
Name Type Description
options

Options.

Name Type Description
features Array.<ol.Feature> | ol.Collection.<ol.Feature> | undefined experimental

Features.

map ol.Map | undefined experimental

Map.

style ol.style.Style | Array.<ol.style.Style> | ol.style.StyleFunction | undefined experimental

Feature style.

Methods

addFeature(feature) experimental

src/ol/featureoverlay.js, line 103

Add a feature to the overlay.

Name Type Description
feature ol.Feature

Feature.

getFeatures(){ol.Collection.<ol.Feature>} experimental

src/ol/featureoverlay.js, line 113

Get the features on the overlay.

Returns:
Features collection.

getMap(){ol.Map} experimental

src/ol/featureoverlay.js, line 123

Get the map associated with the overlay.

Returns:
The map with which this feature overlay is associated.

getStyle(){ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction} experimental

src/ol/featureoverlay.js, line 314

Get the style for features. This returns whatever was passed to the style option at construction or to the setStyle method.

Returns:
Overlay style.

getStyleFunction(){ol.style.StyleFunction|undefined} experimental

src/ol/featureoverlay.js, line 324

Get the style function.

Returns:
Style function.

removeFeature(feature) experimental

src/ol/featureoverlay.js, line 221

Remove a feature from the overlay.

Name Type Description
feature ol.Feature

The feature to be removed.

setFeatures(features) experimental

src/ol/featureoverlay.js, line 241

Set the features for the overlay.

Name Type Description
features ol.Collection.<ol.Feature>

Features collection.

setMap(map) experimental

src/ol/featureoverlay.js, line 276

Set the map for the overlay.

Name Type Description
map ol.Map

Map.

setStyle(style) experimental

src/ol/featureoverlay.js, line 300

Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles.

Name Type Description
style ol.style.Style | Array.<ol.style.Style> | ol.style.StyleFunction

Overlay style.