Dedicated module for icon anchor units enum

This commit is contained in:
Tim Schaub
2016-12-27 10:26:11 -07:00
parent cbe82913b4
commit 02edf0ab24
5 changed files with 37 additions and 35 deletions
+9 -18
View File
@@ -6,6 +6,7 @@ goog.require('ol.asserts');
goog.require('ol.color');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.style.IconAnchorUnits');
goog.require('ol.style.IconImage');
goog.require('ol.style.IconOrigin');
goog.require('ol.style.Image');
@@ -45,17 +46,17 @@ ol.style.Icon = function(opt_options) {
/**
* @private
* @type {ol.style.Icon.AnchorUnits}
* @type {ol.style.IconAnchorUnits}
*/
this.anchorXUnits_ = options.anchorXUnits !== undefined ?
options.anchorXUnits : ol.style.Icon.AnchorUnits.FRACTION;
options.anchorXUnits : ol.style.IconAnchorUnits.FRACTION;
/**
* @private
* @type {ol.style.Icon.AnchorUnits}
* @type {ol.style.IconAnchorUnits}
*/
this.anchorYUnits_ = options.anchorYUnits !== undefined ?
options.anchorYUnits : ol.style.Icon.AnchorUnits.FRACTION;
options.anchorYUnits : ol.style.IconAnchorUnits.FRACTION;
/**
* @private
@@ -225,16 +226,16 @@ ol.style.Icon.prototype.getAnchor = function() {
}
var anchor = this.anchor_;
var size = this.getSize();
if (this.anchorXUnits_ == ol.style.Icon.AnchorUnits.FRACTION ||
this.anchorYUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION ||
this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) {
if (!size) {
return null;
}
anchor = this.anchor_.slice();
if (this.anchorXUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION) {
anchor[0] *= size[0];
}
if (this.anchorYUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
if (this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) {
anchor[1] *= size[1];
}
}
@@ -392,13 +393,3 @@ ol.style.Icon.prototype.unlistenImageChange = function(listener, thisArg) {
ol.events.unlisten(this.iconImage_, ol.events.EventType.CHANGE,
listener, thisArg);
};
/**
* Icon anchor units. One of 'fraction', 'pixels'.
* @enum {string}
*/
ol.style.Icon.AnchorUnits = {
FRACTION: 'fraction',
PIXELS: 'pixels'
};
+10
View File
@@ -0,0 +1,10 @@
goog.provide('ol.style.IconAnchorUnits');
/**
* Icon anchor units. One of 'fraction', 'pixels'.
* @enum {string}
*/
ol.style.IconAnchorUnits = {
FRACTION: 'fraction',
PIXELS: 'pixels'
};