diff --git a/externs/olx.js b/externs/olx.js index c939b81be9..a0c3d4933b 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -4365,6 +4365,7 @@ olx.style.FillOptions.prototype.color; * anchorXUnits: (ol.style.IconAnchorUnits|undefined), * anchorYUnits: (ol.style.IconAnchorUnits|undefined), * crossOrigin: (null|string|undefined), + * origin: (Array.|undefined), * scale: (number|undefined), * rotateWithView: (boolean|undefined), * rotation: (number|undefined), @@ -4415,6 +4416,15 @@ olx.style.IconOptions.prototype.anchorYUnits; olx.style.IconOptions.prototype.crossOrigin; +/** + * The top left corner, which, together with the size, define the + * sub-rectangle to use from the original icon image. Default value + * is `[0, 0]`. + * @type {Array.|undefined} + */ +olx.style.IconOptions.prototype.origin; + + /** * Scale. * @type {number|undefined} diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index 34e4e4c71a..8504431bd6 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -70,6 +70,7 @@ ol.style.Circle = function(opt_options) { goog.base(this, { opacity: 1, + origin: [0, 0], rotateWithView: false, rotation: 0, scale: 1, diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index b3f6f148de..3b5c00b0d4 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -102,6 +102,12 @@ ol.style.Icon = function(opt_options) { */ var opacity = goog.isDef(options.opacity) ? options.opacity : 1; + /** + * @private + * @type {Array.} + */ + var origin = goog.isDef(options.origin) ? options.origin : [0, 0]; + /** * @type {boolean} */ @@ -120,6 +126,7 @@ ol.style.Icon = function(opt_options) { goog.base(this, { opacity: opacity, + origin: origin, rotation: rotation, scale: scale, snapToPixel: undefined, diff --git a/src/ol/style/imagestyle.js b/src/ol/style/imagestyle.js index 3928d92a5c..7fe5b08a87 100644 --- a/src/ol/style/imagestyle.js +++ b/src/ol/style/imagestyle.js @@ -17,6 +17,7 @@ ol.style.ImageState = { /** * @typedef {{opacity: number, + * origin: Array., * rotateWithView: boolean, * rotation: number, * scale: number, @@ -39,6 +40,12 @@ ol.style.Image = function(options) { */ this.opacity_ = options.opacity; + /** + * @private + * @type {Array.} + */ + this.origin_ = options.origin; + /** * @private * @type {boolean} @@ -74,6 +81,14 @@ ol.style.Image.prototype.getOpacity = function() { }; +/** + * @return {Array.} Origin. + */ +ol.style.Image.prototype.getOrigin = function() { + return this.origin_; +}; + + /** * @return {boolean} Rotate with map. */