Skip to content

Commit

Permalink
setOpacity on RasterLayers
Browse files Browse the repository at this point in the history
  • Loading branch information
Saulzi committed Jan 3, 2017
1 parent a18b692 commit 1066630
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions spec/Layers/RasterLayerSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-env mocha */
/* eslint-disable handle-callback-err */
describe('L.esri.RasterLayer', function () {
it('should not error when calling setOpacity when _currentImage is null', function () {
var layer = new L.esri.RasterLayer();
layer._currentImage = null;
expect(function () { layer.setOpacity(0.5); }).to.not.throw();
});
});
4 changes: 3 additions & 1 deletion src/Layers/RasterLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export var RasterLayer = L.Layer.extend({

setOpacity: function (opacity) {
this.options.opacity = opacity;
this._currentImage.setOpacity(opacity);
if (this._currentImage) {
this._currentImage.setOpacity(opacity);
}
return this;
},

Expand Down

0 comments on commit 1066630

Please sign in to comment.