Class: ThemeLayer

mapboxgl.supermap.ThemeLayer

The base theme layer class.

new mapboxgl.supermap.ThemeLayer(name, options)

ThemeLayer.js, line 16
Name Type Description
name string

The name of the thematic layer.

options Object

The optional parameters.

Name Type Default Description
map mapboxgl.Map

The current mapboxgl map object will be deprecated in the next version. Please add a layer using the map.addLayer() method.

id string optional

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

loadWhileAnimating boolean true optional

Whether to redraw in real time.

visibility boolean true optional

Whether the layer is visible.

opacity number 1 optional

The opacity of the layer.

Fires

Members

idstring

Thematic layer ID.

loadWhileAnimatingboolean

Whether to redraw in real time.(It is recommended to draw a large amount of data elements, it is recommended to set this parameter to false).

Default Value:
true

Map object.

namestring

The name of the thematic layer.

opacityfloat

The opacity of the layer.

Default Value:
1

visibilityboolean

Whether the layer is visible.

Default Value:
true

Events

changelayer

ThemeLayer.js, line 191

Fires after the layer property changes.

Properties:
Name Type Description
layer Object

Layer.

property string

The changed attribute.

featuresremoved

ThemeLayer.js, line 256

Triggered after the feature is deleted.

Properties:
Name Type Description
features Array.<SuperMap.Feature.Vector>

Features that have not been successfully deleted.

succeed boolean

The deletion is successful or not.

Methods

addFeatures(features)

ThemeLayer.js, line 202

An abstract method that instantiates a subclass must implement this method. Add data to the thematic map layer, The thematic map only receives data of type SuperMap.Feature.Vector, The feature will be stored in the features property, which is stored as an array.

Name Type Description
features mapboxgl.supermap.ThemeFeature | SuperMap.ServerFeature | GeoJSONObject

The elements to be converted include the mapboxgl.supermap.ThemeFeature type and the GeoJOSN specification data type.

destroyFeatures(features)

ThemeLayer.js, line 138

Destroy an element.

Name Type Description
features SuperMap.Feature.Vector

The elements that will be destroyed.

display(display)

ThemeLayer.js, line 169

Temporarily hide or show layers. Re-rendering fails by producing immediate effects on CSS controls. The setVisibility method is generally used to dynamically control the display and hiding of layers.

Name Type Description
display boolean optional

Whether to display the layer.

getFeatureBy(property, value){SuperMap.Feature.Vector}

ThemeLayer.js, line 291

Traverses each feature in the feature array features of the thematic map, and returns this feature when feature[property] === value (and returns only the first one).

Name Type Description
property string

The property name of the feature

value string

The value corresponding to property.

Returns:
Type Description
SuperMap.Feature.Vector The first vector feature that matches the attribute and the value.

getFeatureById(featureId){SuperMap.Feature.Vector}

ThemeLayer.js, line 310

Returns the corresponding vector element by giving an id.

Name Type Description
featureId string

The id property of the vector feature

Returns:
Type Description
SuperMap.Feature.Vector The feature corresponding to the id. If it does not exist, return to null.

getFeatures(){SuperMap.Feature.Vector}

ThemeLayer.js, line 277

Get the valid features in the current layer.

Returns:
Type Description
SuperMap.Feature.Vector Return the valid features in the layer.

getFeaturesByAttribute(attrName, attrValue){Array.<SuperMap.Feature.Vector>}

ThemeLayer.js, line 320

Return an array contains all the matched features by giving a key and a value of a an attribute.

Name Type Description
attrName string

The key of the attribute.

attrValue string

The value of the attribute.

Returns:
Type Description
Array.<SuperMap.Feature.Vector> An array contains all the matched features.

getLocalXY(coordinate)

ThemeLayer.js, line 396

Convert the Geographic coordinates to Pixel coordinates.

Name Type Description
coordinate Object optional

The coordinate position.

moveTo(layerID, before)

ThemeLayer.js, line 569

Move the layer before a layer.

Name Type Default Description
layerID string

The layer ID to be inserted.

before boolean true optional

Whether to insert this layer before the layer whose layer id is layerID (if it is false, insert this layer after the layer whose layer id is layerID).

off(event, callback, context)

ThemeLayer.js, line 365

Remove event listeners of the thematic elements.

Name Type Description
event Event

The event listener.

callback function

The callback.

context string

The context.

on(event, callback, context)

ThemeLayer.js, line 349

Add event listeners of the thematic features.

Name Type Description
event Event

The event listener.

callback function

The callback.

context string

The context.

onAdd()

ThemeLayer.js, line 79

Add the layer to the basemap.

redrawThematicFeatures(extent)

ThemeLayer.js, line 341

Redraw thematic features. It is an abstract function. This function should be implemented by instantiable subclasses.

Name Type Description
extent mapboxgl.LngLatBounds

The bounds of redrawing the thematic feature.

removeAllFeatures()

ThemeLayer.js, line 265

Remove all vector features on the current layer.

removeFeatures(features)

ThemeLayer.js, line 213

Remove feature from the thematic map. This function removes all vector features passed in. Each item in the features array in the argument must be a feature that has been added to the current layer. If you are unsure of the feature array, you can call removeAllFeatures to remove all features. If there are a lot of elements in the feature array to delete, it is recommended to use removeAllFeatures, Remove all features and add them again. This will be more efficient.

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

To delete an array of features.

removeFromMap()

ThemeLayer.js, line 560

Remove the layer.

setOpacity(opacity)

ThemeLayer.js, line 178

Set the opacity of the layer, between values [0-1].

Name Type Description
opacity number optional

Opacity.

setVisibility(visibility)

ThemeLayer.js, line 156

Set layer visibility, set the layer's hidden, display, and redraw corresponding visible markers.

Name Type Description
visibility boolean optional

Whether to display the layer(The current map's resolution is between the maximum and minimum resolutions).

toFeature(features){SuperMap.Feature.Vector}

ThemeLayer.js, line 414

Convert to the feature in iClient.

Name Type Description
features mapboxgl.supermap.ThemeFeature | GeoJSONObject

The elements to be converted include the mapboxgl.supermap.ThemeFeature type and the GeoJOSN specification data type.

Returns:
Type Description
SuperMap.Feature.Vector The converted iClient element.

toFeature(features){SuperMap.Feature.Vector}

ThemeLayer.js, line 448

Converted to an iClient element, this method will be deprecated and replaced by mapboxgl.supermap.ThemeLayer#toiClientFeature.

Name Type Description
features mapboxgl.supermap.ThemeFeature | GeoJSONObject

The elements to be converted include the mapboxgl.supermap.ThemeFeature type and the GeoJOSN specification data type.

Deprecated
  • Yes
Returns:
Type Description
SuperMap.Feature.Vector The converted iClient element.