Class: Label

ol.source.Label

The Label class.

new ol.source.Label(name, opt_options)

Label.js, line 15
Name Type Default Description
name string

The name of the layer.

opt_options Object

parameters.

Name Type Default Description
map ol.Map

The map object for OpenLayers.

themeField string

Specifies to create a thematic map field.

id string optional

Theme layer ID. The theme layer ID is created by default using CommonUtil.createUniqueID("themeLayer_").

opacity number 1 optional

Layer opacity.

logo string optional

Logo。

projection ol.proj.Projection optional

Projection information.

ratio number 1.5 optional

View ratio, 1 means that the canvas is the size of the map viewport, 2 means that the canvas is twice the width and height of the map viewport, and so on. Must be 1 or higher.

resolutions Array optional

Resolution array.

opt_option.state ol.source.State optional

Resource status.

opt_options.style Object optional

Thematic map style.

opt_options.styleGroups Object optional

Each theme type style group.

opt_options.isHoverAble boolean false optional

Whether to enable the hover event.

opt_options.highlightStyle Object optional

The style style that is triggered after the hover event is turned on.

opt_option.attributions string | Object 'Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a></span>' optional

Copyright information.

Extends

  • GeoFeature

Methods

calculateLabelBounds(feature, loc){Array.<Object>}

Label.js, line 464

Get the final range of the label features.

Name Type Description
feature SuperMap.Feature.Vector

The number of label features need to calculate bounds.

loc Object

Location of the label.e.g.{"x":1,"y":1}.

Returns:
Type Description
Array.<Object> uadrilateral node array. For instance: [{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

calculateLabelBounds2(feature, loc){Array.<Object>}

Label.js, line 507

Another algorithm of getting the final range of the label features(according to the width and height of the recorded labels), improving the efficiency of computing bounds.

Name Type Description
feature SuperMap.Feature.Vector

The number of label features need to calculate bounds

loc Object

Location of the label. For instance:{"x":1,"y":1}.

Returns:
Type Description
Array.<Object> uadrilateral node array. For instance: [{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

createThematicFeature(feature){SuperMap.Feature.Theme.Vector}

Label.js, line 96

Create thematic features.

Name Type Description
feature SuperMap.Feature.Vector

Vector feature.

Returns:
Type Description
SuperMap.Feature.Theme.Vector The theme vector feature.

destroy()

Label.js, line 85

Disposes the resource. The property that references resource is set to null

getAvoidInfo(bounds, quadrilateral){Object}

Label.js, line 740

Get avoided information.

Name Type Description
bounds SuperMap.Bounds

The range of map pixel.

quadrilateral Array.<Object>

Quadrilateral node array. For instance: [{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

Returns:
Type Description
Object The avoided information.

getDrawnLabels(labelFeatures){Array.<SuperMap.Feature.Vector>}

Label.js, line 158

Get the label features to be drawn on the layer after (cover) processing.

Name Type Description
labelFeatures Array.<SuperMap.Feature.Vector>

An array of all the label features.

Returns:
Type Description
Array.<SuperMap.Feature.Vector> The final array of label feature to be drawn.

getLabelInfo(){Object}

Label.js, line 587

Get the drawn label information according to the current location, including the width, height and the line number of the label.

Returns:
Type Description
Object The drawn label information.

getLabelPxLocation(feature){Object}

Label.js, line 439

Get the pixel coordinates of label features.

Name Type Description
feature SuperMap.Feature.Vector

Feature of the label.

Returns:
Type Description
Object Location of the label, e.g.{"x":1,"y":1}

getRotatedLocation(x, y, rx, ry, angle){Object}

Label.js, line 715

Get the position of a point after rotating clockwise around the center point of rotation.(This method is used for screen coordinates).

Name Type Description
x number

The abscissa of the rotation point.

y number

The ordinate of the rotation point.

rx number

The abscissa of a rotating center point.

ry number

The ordinate of a rotating center point.

angle number

The angle of rotation.

Returns:
Type Description
Object Coordinate position object after rotation, which contains the attribute x (abscissa), and the attribute y (ordinate).

getStyleByData(feat){Array.<SuperMap.ThemeStyle>}

Label.js, line 313

Get style according to user data (feature).

Name Type Description
feat SuperMap.Feature.Vector

The vector feature object.

Returns:
Type Description
Array.<SuperMap.ThemeStyle> An style array of thematic features.

isPointInPoly(pt, poly){boolean}

Label.js, line 880

Determine whether a point is in a polygon. (Ray method)

Name Type Description
pt Object

A point object that needs to be determined, which contains the attribute x (abscissa), and the attribute y (ordinate).

poly Array.<Object>

Polygon node array. For example, a quadrilateral:[{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

Returns:
Type Description
boolean Whether the point is in a polygon.

isQuadrilateralOverLap(quadrilateral, quadrilateral2){boolean}

Label.js, line 835

Judge whether two quadrangles is overlapped.

Name Type Description
quadrilateral Array.<Object>

Quadrilateral node array. For example:[{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

quadrilateral2 Array.<Object>

Node array of the second quadrilateral.

Returns:
Type Description
boolean whether two quadrangles is overlapped. true means overlapping.

redrawThematicFeatures(bounds)

Label.js, line 122

Redraw all the thematic elements. This function contains all the steps to draw a thematic element, including the conversion of user data to thematic elements, thinning, caching and other steps. This function is called for layer refresh when map roaming.

Name Type Description
bounds Array.<number>

The redrawn region.

removeAllFeatures()

Label.js, line 150

Remove all vector features in the current layer.

removeFeatures(features)

Label.js, line 140

Remove features from the thematic map. This function deletes all passed vector features (data). Each item in the array of features must the feature that has been added to the current layer.

Name Type Description
features SuperMap.Feature.Vector

The feature object to be removed。

rotationBounds(bounds, rotationCenterPoi, angle){Array.<Object>}

Label.js, line 685

rotate the bounds.

Name Type Description
bounds SuperMap.Bounds

The bounds to be rotated.

rotationCenterPoi Object

A point object of rotated center , which contains the attribute x (abscissa), and the attribute y (ordinate).

angle number

The angle of rotation (clockwise).

Returns:
Type Description
Array.<Object> An polygonal nodes array formed after bounds rotation. It's a quadrilateral. For example:[{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}].

setLabelsStyle(labelFeatures){Array.<SuperMap.Feature.Vector>}

Label.js, line 362

Set style of label features.

Name Type Description
labelFeatures Array.<SuperMap.Feature.Vector>

Array of label features need to be set up style.

Returns:
Type Description
Array.<SuperMap.Feature.Vector> Array of label features which are set up with style.

setStyle(feat)

Label.js, line 390

Set style of the label feature.

Name Type Description
feat SuperMap.Feature.Vector

The label feature need to be set in style.