diff --git a/externs/olx.js b/externs/olx.js index 98ae57309d..6e4c60afcf 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6846,8 +6846,8 @@ olx.style.FillOptions.prototype.color; /** * @typedef {{anchor: (Array.|undefined), * anchorOrigin: (ol.style.IconOrigin|undefined), - * anchorXUnits: (ol.style.Icon.AnchorUnits|undefined), - * anchorYUnits: (ol.style.Icon.AnchorUnits|undefined), + * anchorXUnits: (ol.style.IconAnchorUnits|undefined), + * anchorYUnits: (ol.style.IconAnchorUnits|undefined), * color: (ol.Color|string|undefined), * crossOrigin: (null|string|undefined), * img: (Image|HTMLCanvasElement|undefined), @@ -6886,7 +6886,7 @@ olx.style.IconOptions.prototype.anchorOrigin; * Units in which the anchor x value is specified. A value of `'fraction'` * indicates the x value is a fraction of the icon. A value of `'pixels'` * indicates the x value in pixels. Default is `'fraction'`. - * @type {ol.style.Icon.AnchorUnits|undefined} + * @type {ol.style.IconAnchorUnits|undefined} * @api */ olx.style.IconOptions.prototype.anchorXUnits; @@ -6896,7 +6896,7 @@ olx.style.IconOptions.prototype.anchorXUnits; * Units in which the anchor y value is specified. A value of `'fraction'` * indicates the y value is a fraction of the icon. A value of `'pixels'` * indicates the y value in pixels. Default is `'fraction'`. - * @type {ol.style.Icon.AnchorUnits|undefined} + * @type {ol.style.IconAnchorUnits|undefined} * @api */ olx.style.IconOptions.prototype.anchorYUnits; diff --git a/src/ol/format/kml.js b/src/ol/format/kml.js index 1071c9d673..12f4660995 100644 --- a/src/ol/format/kml.js +++ b/src/ol/format/kml.js @@ -27,6 +27,7 @@ goog.require('ol.math'); goog.require('ol.proj'); goog.require('ol.style.Fill'); goog.require('ol.style.Icon'); +goog.require('ol.style.IconAnchorUnits'); goog.require('ol.style.IconOrigin'); goog.require('ol.style.Stroke'); goog.require('ol.style.Style'); @@ -170,19 +171,19 @@ ol.format.KML.createStyleDefaults_ = function() { /** * @const - * @type {ol.style.Icon.AnchorUnits} + * @type {ol.style.IconAnchorUnits} * @private */ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = - ol.style.Icon.AnchorUnits.PIXELS; + ol.style.IconAnchorUnits.PIXELS; /** * @const - * @type {ol.style.Icon.AnchorUnits} + * @type {ol.style.IconAnchorUnits} * @private */ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = - ol.style.Icon.AnchorUnits.PIXELS; + ol.style.IconAnchorUnits.PIXELS; /** * @const @@ -288,12 +289,12 @@ ol.format.KML.createStyleDefaults_ = function() { /** * @const - * @type {Object.} + * @type {Object.} * @private */ ol.format.KML.ICON_ANCHOR_UNITS_MAP_ = { - 'fraction': ol.style.Icon.AnchorUnits.FRACTION, - 'pixels': ol.style.Icon.AnchorUnits.PIXELS + 'fraction': ol.style.IconAnchorUnits.FRACTION, + 'pixels': ol.style.IconAnchorUnits.PIXELS }; @@ -586,8 +587,8 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { anchorYUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_; } else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) { anchor = [0.5, 0]; - anchorXUnits = ol.style.Icon.AnchorUnits.FRACTION; - anchorYUnits = ol.style.Icon.AnchorUnits.FRACTION; + anchorXUnits = ol.style.IconAnchorUnits.FRACTION; + anchorYUnits = ol.style.IconAnchorUnits.FRACTION; } var offset; @@ -2412,9 +2413,9 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) { if (anchor && anchor[0] !== 0 && anchor[1] !== size[1]) { var /** @type {ol.KMLVec2_} */ hotSpot = { x: anchor[0], - xunits: ol.style.Icon.AnchorUnits.PIXELS, + xunits: ol.style.IconAnchorUnits.PIXELS, y: size[1] - anchor[1], - yunits: ol.style.Icon.AnchorUnits.PIXELS + yunits: ol.style.IconAnchorUnits.PIXELS }; properties['hotSpot'] = hotSpot; } diff --git a/src/ol/style/icon.js b/src/ol/style/icon.js index 8146d50ea8..1628fec65c 100644 --- a/src/ol/style/icon.js +++ b/src/ol/style/icon.js @@ -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' -}; diff --git a/src/ol/style/iconanchorunits.js b/src/ol/style/iconanchorunits.js new file mode 100644 index 0000000000..4d18ca034f --- /dev/null +++ b/src/ol/style/iconanchorunits.js @@ -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' +}; diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 10b6cc70e8..6985f6a158 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -284,8 +284,8 @@ ol.ImageLoadFunctionType; /** - * @typedef {{x: number, xunits: (ol.style.Icon.AnchorUnits|undefined), - * y: number, yunits: (ol.style.Icon.AnchorUnits|undefined)}} + * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), + * y: number, yunits: (ol.style.IconAnchorUnits|undefined)}} */ ol.KMLVec2_;