Last updated

API / geotoolkit / map / features / strategies / AnnotationByRule / AnnotationByRule

Class: AnnotationByRule

strategies.AnnotationByRule.AnnotationByRule

The strategy creates annotation according to the rules below.

Example

import {AnnotationByRule} from '@int/geotoolkit/map/features/strategies/AnnotationByRule';
const strategy = new AnnotationByRule({
'expression': (feature) => {
const attr = feature.getAttributes(); // get data attributes
const rate = attr['pop2012'] / attr['pop1985']; // calculate population growth rate
return attr['country_name'] + '(' + rate.toFixed(1) + ')'; // generate annotation label
},
'maxScale': 10000, // show annotation on scale < 10000
});

Example

const strategy = new AnnotationByRule({
'expression': '{city_name} city', // use braces for attribute values
'where': (feature) => { // features that match the clause will be annotated
const attr = feature.getAttributes();
return attr['pop2012'] > 2000;
}
});

Implements

Table of contents

Constructors
Methods

Contents

Constructors

new AnnotationByRule(options)

new AnnotationByRule(options)

Parameters

Name Type Description
optionsOptionsrules options
Methods

getAnnotation

getAnnotation(feature, layer): string

Gets annotation text for a feature

Parameters

Name Type Description
featureAbstractFeaturemap feature
layerAbstractFeatureLayerfeature layer

Returns

string

annotation text

Implementation of

IGetAnnotation.getAnnotation


getClassName

getClassName(): string

Returns

string

Implementation of

IGetAnnotation.getClassName


getClassName

Static getClassName(): string

Returns

string