# new Feature(geometry)
Parameters:
Name | Type | Description |
---|---|---|
geometry |
Geometry
|
Any geometry object: Point, Line, Polygon, MultiPolygon |
- Tutorials:
Example
const point = new Vexcel.Geometry.Point([20,20]);
const feature = new Vexcel.Geometry.Feature(point);
Classes
Methods
# clone() → {Feature.<Geometry>}
Clone this feature. If the original feature has a geometry it is also cloned.
The clone
Feature.<Geometry>
# getBoundingBox() → {Extent}
Get extent/bounding box for feature geometry in geographic coordinates [minx, miny, maxx, maxy]
bounding box
# getGeometry() → {Geometry}
Get the feature's default geometry
The geometry for the feature.
Geometry
# getKeys() → {Array.<string>}
Get a list of object property names.
List of property names.
Array.<string>
# getProperties() → {Object.<string, *>}
Get an object of all property names and values.
Object.
Object.<string, *>
# set(key, value)
Sets a value.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Key name. |
value |
any
|
Value. |
# setGeometry(geometry)
Set the default geometry for the feature.
Parameters:
Name | Type | Description |
---|---|---|
geometry |
Geometry
|
The new geometry. |
# setProperties(values)
Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).
Parameters:
Name | Type | Description |
---|---|---|
values |
Object.<string, *>
|
Values. |
# setStyle(styleopt)
Set the style for the feature to override the layer style. This can be a single style object, an array of styles, or a function that takes a resolution and returns an array of styles. To unset the feature style, call setStyle()
without arguments or a falsey value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
style |
Style
|
<optional> |
Style for this feature. |
# toGeoJSON() → {string}
Convert feature geometry to GeoJSON string with xy coordinates [long, lat]
string
Events
# FEATURE_CLICK
Event triggered when a feature receives a click
Parameters:
Name | Type | Description |
---|---|---|
location |
Location
|
Location of the coordinates for this event |
layer |
VectorLayer
|
Layer for this feature |
Example
feature.addListener(Vexcel.Events.MapEvents.FEATURE_CLICK, (e) => {
console.log(JSON.stringify(e.feature));
});
# FEATURE_HOVER
Event triggered when hovering over a feature in the map
Parameters:
Name | Type | Description |
---|---|---|
location |
Location
|
Location of the coordinates for this event |
layer |
VectorLayer
|
Layer for this feature |
hover |
boolean
|
if the feature is hovered or not. False it's triggered when pointer does not intersect when the geometry |
Example
feature.addListener(Vexcel.Events.MapEvents.FEATURE_HOVER, (e) => {
console.log(JSON.stringify(e.feature));
});