Fix for undefined source in Image layer

Prevent error if layer does not have a source.  Also clear any existing image if source is set to null or undefined by setSource.
This commit is contained in:
mike-000
2020-01-01 22:04:10 +00:00
committed by GitHub
parent 6063021792
commit 5b1df4438d
+4
View File
@@ -55,6 +55,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
} }
if (!hints[ViewHint.ANIMATING] && !hints[ViewHint.INTERACTING] && !isEmpty(renderedExtent)) { if (!hints[ViewHint.ANIMATING] && !hints[ViewHint.INTERACTING] && !isEmpty(renderedExtent)) {
if (imageSource) {
let projection = viewState.projection; let projection = viewState.projection;
if (!ENABLE_RASTER_REPROJECTION) { if (!ENABLE_RASTER_REPROJECTION) {
const sourceProjection = imageSource.getProjection(); const sourceProjection = imageSource.getProjection();
@@ -66,6 +67,9 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
if (image && this.loadImage(image)) { if (image && this.loadImage(image)) {
this.image_ = image; this.image_ = image;
} }
} else {
this.image_ = null;
}
} }
return !!this.image_; return !!this.image_;