API / geotoolkit / map / features / strategies / AnnotationByRule / 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;
}
});Constructors
Methods
▸ getAnnotation(feature, layer): string
Gets annotation text for a feature
| Name | Type | Description |
|---|---|---|
feature | AbstractFeature | map feature |
layer | AbstractFeatureLayer | feature layer |
string
annotation text
▸ getClassName(): string
string
▸ Static getClassName(): string
string