M/layer/Vector~Vector


import Vector from 'M/layer/Vector';

Main constructor of the class. Creates a Vector layer with parameters specified by the user

new Vector(userParameters, options, vendorOptions)

facade/js/layer/Vector.js, line 35
Name Type Description
userParameters Mx.parameters.Layer

parameters

options Mx.parameters.LayerOptions

custom options for this layer

vendorOptions Object

vendor options for the base library

Extends

  • M.Layer

Members

module:M/layer/Vector~Vector.DEFAULT_OPTIONS_STYLE{object}

Default style for Vector layers

module:M/layer/Vector~Vector.DEFAULT_PARAMS{object}

Default params for style vector layers

Methods

addFeatures(features, update)

facade/js/layer/Vector.js, line 127

Adds features to layer. Only features that are not already in the layer will be added. Two features are equal if the have the same id.

Name Type Default Description
features Array.<M.feature> | M.feature

Features to add

update boolean false

Update layer

calculateMaxExtent(){Promise}

facade/js/layer/Vector.js, line 473

Calculates the max extent of the layer

Returns:
Promise object representing the maxExtent of the layer

clear()

facade/js/layer/Vector.js, line 205

Removes all features and filter from the layer

clearStyle()

facade/js/layer/Vector.js, line 411

Removes the style of the layer, both at layer and at feature level

equals(obj){boolean}

facade/js/layer/Vector.js, line 327

Checks if an object is equal to this layer. Two vector layers are equal if they are Vector type and both have the same name.

Name Type Description
obj object

Object to compare

Returns:
True if equal, false otherwise

getFeatureById(id){null|M.feature}

facade/js/layer/Vector.js, line 172

Searchs and returns the feature with this id, if any.

Name Type Description
id string | number

Id ofthe feature

Returns:
Feature with id, if it is found, null otherwise

getFeatures(skipFilter){Array.<M.Feature>}

facade/js/layer/Vector.js, line 157

Returns all features. If the layer has a Filter, it can skip it and return all features, or apply it and return only features that comply with the Filter (default behaviour).

Name Type Default Description
skipFilter boolean false

Indicates whether skip the layer filter, if any.

Returns:
Features

getFeaturesExtent(skipFilter){Array.<number>}

facade/js/layer/Vector.js, line 299

Returns the minimun extent that contains all features, skipping the layer filter, if set, or not.

Name Type Default Description
skipFilter boolean false

Indicates whether to slkip filter

Returns:
Extent that contains all the features

getFilter(){M.Filter|null}

facade/js/layer/Vector.js, line 286

Returns the filter of the layer, if any, null otherwise

Returns:
Filter assigned to the layer

getGeometryType(){string}

facade/js/layer/Vector.js, line 444

Gets the geometry type of the layer.

Returns:
geometry type of layer

getLegendURL(){string}

facade/js/layer/Vector.js, line 424

Builds an image for the legend for this layer, or returns the url of an image if previously set as legend

Returns:
png image in base64 or url

getMaxExtent(){Array.<number>}

facade/js/layer/Vector.js, line 462

Gets the minimum extent that includes all features from this layer

Returns:
Minimun extent that contains all the features

getStyle(){M.Style}

facade/js/layer/Vector.js, line 400

Returns the style of the layer

Returns:
The style of the layer

redraw()

facade/js/layer/Vector.js, line 229

Redraws the layer

refresh()

facade/js/layer/Vector.js, line 217

Refreshes the layer

removeFeatures(features)

facade/js/layer/Vector.js, line 190

Removes the features indicated

Name Type Description
features Array.<M.feature> | M.feature

Features to remove

removeFilter()

facade/js/layer/Vector.js, line 312

Removes the current filter. All previously filtered features will be active again.

setFilter(filter)

facade/js/layer/Vector.js, line 255

Sets a filter to the layer. Only features that comply with the filter are active as long as the filter is set.

Name Type Description
filter M.Filter

filter to set

setStyle(style, applyToFeature)

facade/js/layer/Vector.js, line 346

Sets a style to the layer

Name Type Default Description
style M.Style
applyToFeature boolean false

True to apply the style at layer level, false to apply style to each feature

toGeoJSON(){Object}

facade/js/layer/Vector.js, line 483

Generates the GeoJSON representation of the layer

Returns:
Layer in GeoJSON format