Mutable symbolizer properties for style functions
This change adds setters for symbolizer properties. In addition, it introduces a mutable flag on all styles. By default, this is set to true. ol.style.createStyleFunction sets it to false for all static styles. The new setters assert that the mutable flag is true, so whenever an application tries to set a symbolizer property on a style that was assigned to a vector layer or feature overlay, the assertion will fail.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
goog.provide('ol.style.Image');
|
||||
goog.provide('ol.style.ImageState');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
@@ -63,6 +65,12 @@ ol.style.Image = function(options) {
|
||||
*/
|
||||
this.snapToPixel_ = options.snapToPixel;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.mutable_ = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -150,6 +158,61 @@ ol.style.Image.prototype.getOrigin = goog.abstractMethod;
|
||||
ol.style.Image.prototype.getSize = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} opacity Opacity.
|
||||
*/
|
||||
ol.style.Image.prototype.setOpacity = function(opacity) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.opacity_ = opacity;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} rotateWithView Rotate with map.
|
||||
*/
|
||||
ol.style.Image.prototype.setRotateWithView = function(rotateWithView) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.rotateWithView_ = rotateWithView;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} rotation Rotation.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Image.prototype.setRotation = function(rotation) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.rotation_ = rotation;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} scale Scale.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Image.prototype.setScale = function(scale) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.scale_ = scale;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} snapToPixel Snap to pixel?
|
||||
*/
|
||||
ol.style.Image.prototype.setSnapToPixel = function(snapToPixel) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.snapToPixel_ = snapToPixel;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} mutable Mutable.
|
||||
*/
|
||||
ol.style.Image.prototype.setMutable = function(mutable) {
|
||||
this.mutable_ = mutable;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(this: T, goog.events.Event)} listener Listener function.
|
||||
* @param {T} thisArg Value to use as `this` when executing `listener`.
|
||||
|
||||
Reference in New Issue
Block a user