diff --git a/src/ol/render/canvas.js b/src/ol/render/canvas.js index fd393d5cd6..644158097d 100644 --- a/src/ol/render/canvas.js +++ b/src/ol/render/canvas.js @@ -61,7 +61,7 @@ import {getFontParameters} from '../css.js'; * @property {string} [textAlign] TextAlign. * @property {string} [justify] Justify. * @property {string} textBaseline TextBaseline. - * @property {string} [placement] Placement. + * @property {import('../style/Text.js').TextPlacement} [placement] Placement. * @property {number} [maxAngle] MaxAngle. * @property {boolean} [overflow] Overflow. * @property {import("../style/Fill.js").default} [backgroundFill] BackgroundFill. diff --git a/src/ol/render/canvas/TextBuilder.js b/src/ol/render/canvas/TextBuilder.js index df9ec4218d..a8eab29930 100644 --- a/src/ol/render/canvas/TextBuilder.js +++ b/src/ol/render/canvas/TextBuilder.js @@ -3,7 +3,6 @@ */ import CanvasBuilder from './Builder.js'; import CanvasInstruction from './Instruction.js'; -import TextPlacement from '../../style/TextPlacement.js'; import {asColorLike} from '../../colorlike.js'; import { defaultFillStyle, @@ -177,7 +176,7 @@ class CanvasTextBuilder extends CanvasBuilder { let stride = geometry.getStride(); if ( - textState.placement === TextPlacement.LINE && + textState.placement === 'line' && (geometryType == 'LineString' || geometryType == 'MultiLineString' || geometryType == 'Polygon' || diff --git a/src/ol/style/Text.js b/src/ol/style/Text.js index 1337f88187..3bc20c6545 100644 --- a/src/ol/style/Text.js +++ b/src/ol/style/Text.js @@ -2,9 +2,16 @@ * @module ol/style/Text */ import Fill from './Fill.js'; -import TextPlacement from './TextPlacement.js'; import {toSize} from '../size.js'; +/** + * @typedef {'point' | 'line'} TextPlacement + * Default text placement is `'point'`. Note that + * `'line'` requires the underlying geometry to be a {@link module:ol/geom/LineString~LineString}, + * {@link module:ol/geom/Polygon~Polygon}, {@link module:ol/geom/MultiLineString~MultiLineString} or + * {@link module:ol/geom/MultiPolygon~MultiPolygon}. + */ + /** * The default fill color to use if no fill was set at construction time; a * blackish `#333`. @@ -23,7 +30,7 @@ const DEFAULT_FILL_COLOR = '#333'; * @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down. * @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed * the width of the polygon at the label position or the length of the path that it follows. - * @property {import("./TextPlacement.js").default|string} [placement='point'] Text placement. + * @property {TextPlacement} [placement='point'] Text placement. * @property {number|import("../size.js").Size} [scale] Scale. * @property {boolean} [rotateWithView=false] Whether to rotate the text with the view. * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise). @@ -135,10 +142,10 @@ class Text { /** * @private - * @type {import("./TextPlacement.js").default|string} + * @type {TextPlacement} */ this.placement_ = - options.placement !== undefined ? options.placement : TextPlacement.POINT; + options.placement !== undefined ? options.placement : 'point'; /** * @private @@ -249,7 +256,7 @@ class Text { /** * Get the label placement. - * @return {import("./TextPlacement.js").default|string} Text placement. + * @return {TextPlacement} Text placement. * @api */ getPlacement() { @@ -443,7 +450,7 @@ class Text { /** * Set the text placement. * - * @param {import("./TextPlacement.js").default|string} placement Placement. + * @param {TextPlacement} placement Placement. * @api */ setPlacement(placement) { diff --git a/src/ol/style/TextPlacement.js b/src/ol/style/TextPlacement.js deleted file mode 100644 index fb05299494..0000000000 --- a/src/ol/style/TextPlacement.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @module ol/style/TextPlacement - */ - -/** - * Text placement. One of `'point'`, `'line'`. Default is `'point'`. Note that - * `'line'` requires the underlying geometry to be a {@link module:ol/geom/LineString~LineString}, - * {@link module:ol/geom/Polygon~Polygon}, {@link module:ol/geom/MultiLineString~MultiLineString} or - * {@link module:ol/geom/MultiPolygon~MultiPolygon}. - * @enum {string} - */ -export default { - POINT: 'point', - LINE: 'line', -};