Last updated

API / geotoolkit / map / features / formatters / Table / Table

Class: Table

formatters.Table.Table

Features info formatter that creates table based on the one attribute field.

Implements

Table of contents

Constructors
Methods

Contents

Constructors

new Table(fields, vertical)

new Table(fields?, vertical?)

Features info formatter that creates table based on the one attribute field.

Parameters

Name Type Description
Optional fieldsstring[]fields to show in table, all fields are shown if no value provided
Optional verticalbooleantrue 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

format(features, text): string

Formats html text based on the provided features attribute field

Parameters

Name Type Description
featuresAbstractFeature[]features list to format
textstringtext created by the previous formatters from other layers

Returns

string

text the formatted text result

Implementation of

IFormatter.format


getClassName

getClassName(): string

Returns

string


fromObject

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']
});

Parameters

Name Type Description
objRecord<string, (feature: AbstractFeature) => string>fields formatter object
Optional verticalbooleantrue 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

Returns

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']
});
Parameters
Name Type
featuresAbstractFeature[]
textstring
Returns

string


getClassName

Static getClassName(): string

Returns

string