Class: Feature

cercaliagl.Feature


Javascript ES5

const feature = new cercaliagl.Feature({ ... });

A vector object for geographics features with a geometry and other attribute. Feature must need a geometry in GeoJSON format or in WKT format. Then there are many attributes to adjust this feature styles and events.
These events can defined in constructor or in runtime modifing attribute as onClick, onMouseOver, etc.

Example usage:

const feature = new cercaliagl.Feature({
  wkt: 'POLYGON((2.177722861 41.413683777, 2.174677572 41.411310103, 2.171263974 41.413372702, 2.174830286 41.416057364, 2.177722861 41.413683777))',
  strokeColor: '#550000',
  strokeWidth: 2,
  fillOpacity: 0.5,
  simpleLabel: new cercaliagl.SimpleLabel({text: 'Example polygon'}),
  onClick: () => alert('Polygon click'),
});
map.addFeature(feature);
map.centerToFeatures([feature]);

new Feature(options)

Name Type Description
options
Name Type Description
id string

Feature id

editable boolean

Feature editable using mouse. Default false.

fillColor string

Feature fill color. Default value #009BFF.

fillOpacity number

Feature fill opacity. Default value 0.2.

strokeOpacity number

Feature stroke opacity. Default value 1.

strokeColor string

Feature stroke color. Default value #2196F3.

strokeWidth number

Feature stroke width. Default value 7.

outline boolean

Enable outline feature property. If no outline required, specify null. Default value true.

outlineColor string

Feature outline color. Default value #040252.

outlineOpacity number

Feature outline opacity. Default value 1.

outlineWidth number

Feature outline width. Default value 9.

visible boolean

Feature visible or not. Default true.

string encodedGoogleLineString

Linestring wkt encoded on google polyline .

string encodedGooglePolygon

Polygon wkt encoded on google polyline .

visible boolean

Feature visible or not. Default true.

onClick function

Function to execute on marker click.

onDoubleClick function

Function to execute on marker double click.

onMouseOut function

Function to execute on Mouse Out.

onMouseOver function

Function to execute on Mouse Over.

onMouseMove function

Function to execute on Mouse Over.

onRightClick function

Function to execute on marker right click.

onModifyStart function

Function to execute on marker right click.

onModifyEnd function

Function to execute on modify end. When feature is editable.

wkt string

WKT String with shape geometry to be painted. Mandatory to use that or geometry property. More info: https://es.wikipedia.org/wiki/Well_Known_Text

simpleLabel module:cercaliagl/SimpleLabel~SimpleLabel

Marker Simple Label object.

geometry module:cercaliagl/util~GeometryGeoJSON

GeoJSON Geometry. Mandatory to use this property or wkt property. More info: https://geojson.org/ (From geometry property).

zIndex number

Z-Index. Default 0.

Extends

Methods

module:cercaliagl/Feature~Feature.fromGeoJSON(geojsonFeature, featureOptions)

Name Type Description
geojsonFeature Object

GeoJSON feature

featureOptions

Feature options

Name Type Description
id string

Feature id

editable boolean

Feature editable using mouse. Default false.

fillColor string

Feature fill color. Default value #009BFF.

fillOpacity number

Feature fill opacity. Default value 0.2.

strokeOpacity number

Feature stroke opacity. Default value 1.

strokeColor string

Feature stroke color. Default value #2196F3.

strokeWidth number

Feature stroke width. Default value 7.

outline boolean

Enable outline feature property. If no outline required, specify null. Default value true.

outlineColor string

Feature outline color. Default value #040252.

outlineOpacity number

Feature outline opacity. Default value 1.

outlineWidth number

Feature outline width. Default value 9.

visible boolean

Feature visible or not. Default true.

string encodedGoogleLineString

Linestring wkt encoded on google polyline .

string encodedGooglePolygon

Polygon wkt encoded on google polyline .

visible boolean

Feature visible or not. Default true.

onClick function

Function to execute on marker click.

onDoubleClick function

Function to execute on marker double click.

onMouseOut function

Function to execute on Mouse Out.

onMouseOver function

Function to execute on Mouse Over.

onMouseMove function

Function to execute on Mouse Over.

onRightClick function

Function to execute on marker right click.

onModifyStart function

Function to execute on marker right click.

onModifyEnd function

Function to execute on modify end. When feature is editable.

wkt string

WKT String with shape geometry to be painted. Mandatory to use that or geometry property. More info: https://es.wikipedia.org/wiki/Well_Known_Text

simpleLabel module:cercaliagl/SimpleLabel~SimpleLabel

Marker Simple Label object.

geometry module:cercaliagl/util~GeometryGeoJSON

GeoJSON Geometry. Mandatory to use this property or wkt property. More info: https://geojson.org/ (From geometry property).

zIndex number

Z-Index. Default 0.

Gets a value.

Name Type Description
key string

Key name.

Returns:
Value.

Get feature bounds.

getClosestCoordinate(position){LonLat}

Get closest feature coordinate giving a position.

Name Type Description
position LonLat

Position

Returns:
Closest coordinate to point

getFillColor(color)

Name Type Description
color *

Return color in hexadecimal format. For example #ff0000

getFillOpacity(){number}

Get fill opacity

Returns:
Values between 0 and 1.

getGeoJSON(){GeoJSON} inherited

Returns:
GeoJSON

Get feature Geometry

Returns:
Geometry

getGeometryType(){string} inherited

Returns:
GeoJSON

getId(){String} inherited

Returns:
Id
Returns:
Layer
Returns:
Map

getOutlineColor(){string}

Returns:
Return color in hexadecimal format. For example #ff0000

getOutlineOpacity(){number}

Get opacity

Returns:
Opacity. Values between 0 and 1.

getOutlineWidth(){number}

Get outline width

Returns:
Width.

Get simple label object. Returns `nullp if it doesn't exist.

Returns:
Simple label

getStrokeColor(){string}

Returns:
Return color in hexadecimal format. For example #ff0000

getStrokeOpacity(){number}

Get stroke opacity

Returns:
Values between 0 and 1.

getStrokeWidth(){number}

Returns:
Width.

getWKT(){string}

Get geometry in WKT format.

Returns:
Geometry in WKT format

isEditable(){boolean}

Obtain if feature is editable.

Returns:
is editable

isShowingDirection(){boolean}

Obtain if feature is showing direction.

Returns:
is showing direction

isVisible(){boolean}

Obtain if feature is visible

Returns:
Return true if feature is visible

set(key, value, silent) inherited

Sets a value.

Name Type Description
key string

Key name.

value *

Value.

silent boolean

Update without triggering an event.

setEditable(editable)

Set editable feature

Name Type Description
editable boolean

true to become editable feature.

setFillColor(color)

Change feature fill color

Name Type Description
color string

Color in hexadecimal format. For example: #ff0000.

setFillOpacity(opacity)

Fill opacity.

Name Type Description
opacity number

Values between 0 and 1.

setGeometry(geometry)

Set geometry and update it.

Name Type Description
geometry

Geometry

Name Type Description
type string

Geometry type

coordinates Array.<number> | Array.<Array.<number>> | Array.<Array.<Array.<number>>>
Name Type Description
map module:cercaliagl/Map~Map

Map

setOutlineColor(color)

Change feature outline color

Name Type Description
color string

Color in hexadecimal format. For example: #ff0000.

setOutlineOpacity(opacity)

Change outline opacity

Name Type Description
opacity number

Opacity. Values between 0 and 1.

setOutlineWidth(width)

Change feature outline width

Name Type Description
width number

Width.

setShowDirection(showDirection)

Set show direction feature

Name Type Description
showDirection boolean

true to show feature's direction.

setSimpleLabel(simpleLabel)

Set simple label and update it on map.

Name Type Description
simpleLabel module:cercaliagl/SimpleLabel~SimpleLabel | null

simple Label

setStrokeColor(color)

Change feature stroke color

Name Type Description
color string

Color in hexadecimal format. For example: #ff0000.

setStrokeOpacity(opacity)

Stroke opacity.

Name Type Description
opacity number

Values between 0 and 1.

setStrokeWidth(width)

Change feature stroke width

Name Type Description
width number

Width.

setVisible(visible)

Show or hide feature.

Name Type Description
visible boolean

Visible true, not visible false.

setWKT(wkt)

Set geometry in WKT format and update it on map.

Name Type Description
wkt

WKT geometry

Name Type Description
type string

Geometry type

coordinates Array.<number> | Array.<Array.<number>> | Array.<Array.<Array.<number>>>

setZIndex(zIndex)

Set zIndex and update it.

Name Type Description
zIndex number

zIndex