Class: Graphic

ol.source.Graphic

High efficiency point layer source class.

new ol.source.Graphic(options)

Graphic.js, line 38
Name Type Description
options Object

Graphic parameters.

Name Type Default Description
map ol.map

Map object for openlayers.

graphics ol.Graphic

Point features for high efficiency point layers.

render string 'canvas' optional

Specifies the renderer to use. Optional values: "webgl", "canvas" (webgl rendering currently only supports scatter).

isHighLight boolean true optional

Whether the event response supports feature highlighting.

highLightStyle ol.style defaultHighLightStyle optional

The highlight Style.

color Array.<number> [0, 0, 0, 255] optional

The color.

highlightColor Array.<number> optional

The feature highlight color when webgl is rendered.

opacity number 0.8 optional

The opacity.

radius number 10 optional

Feature radius, in pixels.

radiusScale number 1 optional

The magnification of the feature when webgl is rendered.

radiusMinPixels number 0 optional

The minimum radius (pixels).

radiusMaxPixels number Number.MAX_SAFE_INTEGER optional

The maximum radius (pixels).

strokeWidth number 1 optional

The size of the border.

outline boolean false optional

Whether to display the border.

onHover function optional

Layer mouse hover response event (valid only when webgl renders).

onClick function optional

Layer mouse click response events (valid for webgl and canvas rendering).

Extends

Methods

addGraphics(graphics)

Graphic.js, line 243

Adding a point feature does not overwrite the previous feature.

Name Type Description
graphics Array.<ol.Graphic>

An array of point feature objects.

clear()

Graphic.js, line 341

Release layer resources.

getGraphicBy(property, value){ol.Graphic}

Graphic.js, line 255

Traverse each graphic in the Vector's feature array graphics, and return this graphic when graphic[property]===value (and only return the first one).

Name Type Description
property string

A property name for graphic.

value string

The value corresponding to the property.

Returns:
Type Description
ol.Graphic A matching graphic.

getGraphicById(graphicId){ol.Graphic}

Graphic.js, line 273

Returns the corresponding vector element by giving an id.

Name Type Description
graphicId string

Vector attribute id.

Returns:
Type Description
ol.Graphic A matching graphic.

getGraphicsByAttribute(attrName, attrValue){Array.<ol.Graphic>}

Graphic.js, line 283

Returns a matching array of features by giving the key and value of an attribute.

Name Type Description
attrName string

A property name for graphic.

attrValue string

The value corresponding to the property.

Returns:
Type Description
Array.<ol.Graphic> A matching graphic array.

getGraphicsInExtent(extent)

Graphic.js, line 532

Get the geometric feature area in the specified range.

Name Type Description
extent Object

Length range.

getLayerState(){Object}

Graphic.js, line 410

Get the current map and layer status.

Returns:
Type Description
Object Map and layer status, including map status information and related status of this layer.

removeGraphics(graphics)

Graphic.js, line 304

Delete feature arrays, all features will be deleted by default.

Name Type Description
graphics Array.<ol.Graphic> optional

The graphics array to be deleted.

setGraphics(graphics)

Graphic.js, line 230

Set the drawn point features to overwrite all previous features.

Name Type Description
graphics Array.<ol.Graphic>

An array of point feature objects.

setStyle(styleOptions)

Graphic.js, line 378

Set the overall style of the layer features (this interface is only useful when rendering webgl).

Name Type Description
styleOptions Object

Style object.

Name Type Default Description
color Array.<number> [0, 0, 0, 255] optional

Point color.

radius number 10 optional

Point radius.

opacity number 0.8 optional

Opacity.

highlightColor Array optional

Highlight color, currently only supports rgba arrays.

radiusScale number 1 optional

Point magnification.

radiusMinPixels number 0 optional

The minimum radius (pixels).

radiusMaxPixels number Number.MAX_SAFE_INTEGER optional

The maximum radius (pixels).

strokeWidth number 1 optional

The size of the border.

outline boolean false optional

Whether to display the border.

update()

Graphic.js, line 349

Update the layer.