From 9267d2994d7e40443500d9671d7b3d95a462304a Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 25 Oct 2021 10:20:36 +0100 Subject: [PATCH] handle updateable displacement --- src/ol/style/RegularShape.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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]; }