Add "origin" option to ol.style.Image

This commit is contained in:
Éric Lemoine
2014-05-05 09:30:35 +02:00
parent 29d71b34b2
commit a62fd53d36
4 changed files with 33 additions and 0 deletions

View File

@@ -4365,6 +4365,7 @@ olx.style.FillOptions.prototype.color;
* anchorXUnits: (ol.style.IconAnchorUnits|undefined), * anchorXUnits: (ol.style.IconAnchorUnits|undefined),
* anchorYUnits: (ol.style.IconAnchorUnits|undefined), * anchorYUnits: (ol.style.IconAnchorUnits|undefined),
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* origin: (Array.<number>|undefined),
* scale: (number|undefined), * scale: (number|undefined),
* rotateWithView: (boolean|undefined), * rotateWithView: (boolean|undefined),
* rotation: (number|undefined), * rotation: (number|undefined),
@@ -4415,6 +4416,15 @@ olx.style.IconOptions.prototype.anchorYUnits;
olx.style.IconOptions.prototype.crossOrigin; 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.<number>|undefined}
*/
olx.style.IconOptions.prototype.origin;
/** /**
* Scale. * Scale.
* @type {number|undefined} * @type {number|undefined}

View File

@@ -70,6 +70,7 @@ ol.style.Circle = function(opt_options) {
goog.base(this, { goog.base(this, {
opacity: 1, opacity: 1,
origin: [0, 0],
rotateWithView: false, rotateWithView: false,
rotation: 0, rotation: 0,
scale: 1, scale: 1,

View File

@@ -102,6 +102,12 @@ ol.style.Icon = function(opt_options) {
*/ */
var opacity = goog.isDef(options.opacity) ? options.opacity : 1; var opacity = goog.isDef(options.opacity) ? options.opacity : 1;
/**
* @private
* @type {Array.<number>}
*/
var origin = goog.isDef(options.origin) ? options.origin : [0, 0];
/** /**
* @type {boolean} * @type {boolean}
*/ */
@@ -120,6 +126,7 @@ ol.style.Icon = function(opt_options) {
goog.base(this, { goog.base(this, {
opacity: opacity, opacity: opacity,
origin: origin,
rotation: rotation, rotation: rotation,
scale: scale, scale: scale,
snapToPixel: undefined, snapToPixel: undefined,

View File

@@ -17,6 +17,7 @@ ol.style.ImageState = {
/** /**
* @typedef {{opacity: number, * @typedef {{opacity: number,
* origin: Array.<number>,
* rotateWithView: boolean, * rotateWithView: boolean,
* rotation: number, * rotation: number,
* scale: number, * scale: number,
@@ -39,6 +40,12 @@ ol.style.Image = function(options) {
*/ */
this.opacity_ = options.opacity; this.opacity_ = options.opacity;
/**
* @private
* @type {Array.<number>}
*/
this.origin_ = options.origin;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
@@ -74,6 +81,14 @@ ol.style.Image.prototype.getOpacity = function() {
}; };
/**
* @return {Array.<number>} Origin.
*/
ol.style.Image.prototype.getOrigin = function() {
return this.origin_;
};
/** /**
* @return {boolean} Rotate with map. * @return {boolean} Rotate with map.
*/ */