API / geotoolkit / map / features / formatters / Table / Table
formatters.Table.Table
Features info formatter that creates table based on the one attribute field.
Constructors
Constructors
• new Table(fields?, vertical?)
Features info formatter that creates table based on the one attribute field.
| Name | Type | Description |
|---|---|---|
Optional fields | string[] | fields to show in table, all fields are shown if no value provided |
Optional vertical | boolean | true if feature info should be located in a column with the field names at the first. Otherwise features are placed in a row one under another with field names as a header |
Methods
▸ format(features, text): string
Formats html text based on the provided features attribute field
| Name | Type | Description |
|---|---|---|
features | AbstractFeature[] | features list to format |
text | string | text created by the previous formatters from other layers |
string
text the formatted text result
▸ getClassName(): string
string
▸ Static fromObject(obj, vertical?): (features: AbstractFeature[], text: string) => string
Creates table formatter function based on the provided object
Example
import {Table} from '@int/geotoolkit/map/features/formatters/Table';
const formatter = Table.fromObject({
'City': (feature) => feature.getAttributes()['city'] + ', ' + feature.getAttributes()['country']',
'Population': f(feature) => feature.getAttributes()['pop'],
'Latitude': (feature) => feature.getGeometry()['y'],
'Longitude': (feature) => feature.getGeometry()['x']
});| Name | Type | Description |
|---|---|---|
obj | Record<string, (feature: AbstractFeature) => string> | fields formatter object |
Optional vertical | boolean | true if feature info should be located in a column with the field names at the first. Otherwise features are placed in a row one under another with field names as a header |
fn
▸ (features, text): string
Creates table formatter function based on the provided object
Example
import {Table} from '@int/geotoolkit/map/features/formatters/Table';
const formatter = Table.fromObject({
'City': (feature) => feature.getAttributes()['city'] + ', ' + feature.getAttributes()['country']',
'Population': f(feature) => feature.getAttributes()['pop'],
'Latitude': (feature) => feature.getGeometry()['y'],
'Longitude': (feature) => feature.getGeometry()['x']
});| Name | Type |
|---|---|
features | AbstractFeature[] |
text | string |
string
▸ Static getClassName(): string
string