diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index fbac91dc62..920e40565e 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -126,12 +126,6 @@ class RegularShape extends ImageStyle { */ this.stroke_ = options.stroke !== undefined ? options.stroke : null; - /** - * @private - * @type {Array} - */ - this.anchor_ = null; - /** * @private * @type {import("../size.js").Size} @@ -177,7 +171,12 @@ class RegularShape extends ImageStyle { * @api */ getAnchor() { - return this.anchor_; + const size = this.size_; + if (!size) { + return null; + } + const displacement = this.getDisplacement(); + return [size[0] / 2 - displacement[0], size[1] / 2 + displacement[1]]; } /** @@ -467,9 +466,7 @@ class RegularShape extends ImageStyle { render() { this.renderOptions_ = this.createRenderOptions(); const size = this.renderOptions_.size; - const displacement = this.getDisplacement(); this.canvas_ = {}; - this.anchor_ = [size / 2 - displacement[0], size / 2 + displacement[1]]; this.size_ = [size, size]; }