Add getters to ol.style.Image

This commit is contained in:
Éric Lemoine
2013-12-19 13:02:10 +01:00
parent e4f2a7552e
commit 5cd3ab06fc
3 changed files with 75 additions and 17 deletions

View File

@@ -455,18 +455,20 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyles_ = function() {
*/
ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
if (!goog.isNull(imageStyle)) {
goog.asserts.assert(!goog.isNull(imageStyle.anchor));
goog.asserts.assert(goog.isDef(imageStyle.size));
var anchor = imageStyle.getAnchor();
goog.asserts.assert(!goog.isNull(anchor));
var size = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(size));
// FIXME pixel ratio
var image = imageStyle.getImage(1);
goog.asserts.assert(!goog.isNull(image));
var state = this.state_;
state.anchorX = imageStyle.anchor[0];
state.anchorY = imageStyle.anchor[1];
state.anchorX = anchor[0];
state.anchorY = anchor[1];
state.image = image;
state.width = imageStyle.size[0];
state.height = imageStyle.size[1];
state.snapToPixel = imageStyle.snapToPixel;
state.width = size[0];
state.height = size[1];
state.snapToPixel = imageStyle.getSnapToPixel();
}
};

View File

@@ -602,20 +602,22 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
*/
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
goog.asserts.assert(!goog.isNull(imageStyle));
goog.asserts.assert(!goog.isNull(imageStyle.anchor));
goog.asserts.assert(goog.isDef(imageStyle.size));
var anchor = imageStyle.getAnchor();
goog.asserts.assert(!goog.isNull(anchor));
var size = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(size));
// FIXME pixel ratio
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
goog.asserts.assert(!goog.isNull(hitDetectionImage));
var image = imageStyle.getImage(1);
goog.asserts.assert(!goog.isNull(image));
this.anchorX_ = imageStyle.anchor[0];
this.anchorY_ = imageStyle.anchor[1];
this.anchorX_ = anchor[0];
this.anchorY_ = anchor[1];
this.hitDetectionImage_ = hitDetectionImage;
this.image_ = image;
this.width_ = imageStyle.size[0];
this.height_ = imageStyle.size[1];
this.snapToPixel_ = imageStyle.snapToPixel;
this.width_ = size[0];
this.height_ = size[1];
this.snapToPixel_ = imageStyle.getSnapToPixel();
};