new $g.Feature(geometry, propertiesopt)
Constructs a new Feature.
Name | Type | Attributes | Description |
---|---|---|---|
geometry | $g. | The feature's geometry | |
properties | object | <optional> | Properties for the feature. The values should be strings. |
- Since
- 6.0.0
Members
geometry :$g.Geometry
The geometry associated with this feature.
- Since
- 6.0.0
(readonly) properties :object
The properties associated with this feature. Modifying this property directly has no effect, use .setProperty() instead.
- object
- Since
- 6.0.0
Methods
(static) fromElement(element, geometry) → {$g.Feature}
Creates a feature from the given semantic element or hit.
Name | Type | Description |
---|---|---|
element | $k. | The semantic element or hit |
geometry | $g. | The feature's geometry or the internal name of a geometry attribute type |
- Since
- 6.0.0
If the second argument referes to an attribute type that has no (unique) value at the element
- Type:
- $g.
Feature
setColor(color)
Sets the color for this feature's geometry on the map.
Name | Type | Description |
---|---|---|
color | $k. | Color value, color name (e.g. 'red') or hex value (e.g. '#ff0000') |
- Since
- 6.0.0
setElement(element)
Sets the semantic element associated with this feature, e.g. for click actions and tooltips.
Name | Type | Description |
---|---|---|
element | $k. | The semantic element |
- Since
- 6.0.0
setGeometry(geometry)
Sets the geometry associated with this feature.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry |
- Since
- 6.0.0
setIcon(icon)
Sets the icon for this feature that is shown in map markers.
Name | Type | Description |
---|---|---|
icon | $k. | The icon attribute or blob. An id string of an icon attribute is also accepted. |
- Since
- 6.0.0
If the argument is not an Attribute, Blob or string
If the argument is an Attribute of the wrong value type
setProperty(property, value)
Sets a custom property to be included in the GeoJSON's properties object.
Name | Type | Description |
---|---|---|
property | string | Name of the property |
value | any | Value of the property |
- Since
- 6.0.0
setTooltip(tooltip)
Sets the tooltip for this feature that is shown when hovering over it. The tooltip supports basic formatting using HTML.
Name | Type | Description |
---|---|---|
tooltip | string | The tooltip (HTML) string |
- Since
- 6.0.0
toGeoJSON() → {object}
Creates a GeoJSON object from this feature. Note that all property values not representable in JSON will be omitted.
- Since
- 6.0.0
If this feature has no geometry assigned or cannot be represented as GeoJSON for some other reason.
GeoJSON object.
- Type:
- object