diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index d5b29b76c1..b3f6f148de 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -52,6 +52,12 @@ ol.style.Icon = function(opt_options) { */ this.anchor_ = goog.isDef(options.anchor) ? options.anchor : [0.5, 0.5]; + /** + * @private + * @type {Array.} + */ + this.normalizedAnchor_ = null; + /** * @private * @type {ol.style.IconAnchorOrigin} @@ -129,6 +135,9 @@ goog.inherits(ol.style.Icon, ol.style.Image); * @todo api */ ol.style.Icon.prototype.getAnchor = function() { + if (!goog.isNull(this.normalizedAnchor_)) { + return this.normalizedAnchor_; + } var anchor = this.anchor_; var size = this.getSize(); if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION || @@ -161,7 +170,8 @@ ol.style.Icon.prototype.getAnchor = function() { anchor[1] = -anchor[1] + size[1]; } } - return anchor; + this.normalizedAnchor_ = anchor; + return this.normalizedAnchor_; };