Skip to content

Commit

Permalink
Merge pull request Esri#909 from Saulzi/setOpacity
Browse files Browse the repository at this point in the history
setOpacity on RasterLayers
  • Loading branch information
jgravois committed Jan 4, 2017
2 parents 3f45418 + 9d3023f commit 5d9bd90
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 5d9bd90

Please sign in to comment.