From 34361f4a7f591e659756d89e8be321443c610441 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Thu, 25 Apr 2024 11:39:52 +0700 Subject: [PATCH] Add Text customizer. --- src/BaseCustomizer.ts | 18 ++++++++++++++++-- src/VectorEncoder.ts | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/BaseCustomizer.ts b/src/BaseCustomizer.ts index 0c7cddb..6deece5 100644 --- a/src/BaseCustomizer.ts +++ b/src/BaseCustomizer.ts @@ -1,8 +1,14 @@ import type {Geometry} from 'ol/geom.js'; import type {State} from 'ol/layer/Layer.js'; import type {WMTS, TileWMS} from 'ol/source.js'; -import type {Image, Stroke} from 'ol/style.js'; -import type {MFPWmsLayer, MFPSymbolizerLine, MFPSymbolizerPoint, MFPWmtsLayer} from './types'; +import type {Image, Stroke, Text} from 'ol/style.js'; +import type { + MFPWmsLayer, + MFPSymbolizerLine, + MFPSymbolizerPoint, + MFPWmtsLayer, + MFPSymbolizerText, +} from './types'; import type {Feature as GeoJSONFeature} from 'geojson'; /** @@ -71,6 +77,14 @@ export default class BaseCustomizer { */ point(layerState: State, symbolizer: MFPSymbolizerPoint, image: Image) {} + /** + * Can be used to manipulate the text symbolizers + * @param layerState + * @param symbolizer + * @param text + */ + text(layerState: State, symbolizer: MFPSymbolizerText, text: Text) {} + /** * Can be used to manipulate a converted WMTS layer * @param layerState diff --git a/src/VectorEncoder.ts b/src/VectorEncoder.ts index 9da5266..57df0a5 100644 --- a/src/VectorEncoder.ts +++ b/src/VectorEncoder.ts @@ -547,6 +547,7 @@ export default class VectorEncoder { symbolizer.haloRadius = strokeWidth; } } + this.customizer_.text(this.layerState_, symbolizer, textStyle); symbolizers.push(symbolizer); } }