New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dynamic background color #14895
Fix dynamic background color #14895
Conversation
📦 Preview the website for this branch here: https://deploy-preview-14895--ol-site.netlify.app/. |
I'm not sure what should happen if the background function returns If you want something like this; --- test/browser/spec/ol/renderer/canvas/vectortilelayer.test.js
+++ test/browser/spec/ol/renderer/canvas/vectortilelayer.test.js
@@ -334,6 +334,7 @@ describe('ol/renderer/canvas/VectorTileLayer', function () {
undefined,
'rgba(255, 0, 0, 0.5)',
'rgba(0, 0, 255, 0.5)',
+ undefined,
];
expect(resolution).to.be(map.getView().getResolution());
@@ -349,6 +350,8 @@ describe('ol/renderer/canvas/VectorTileLayer', function () {
expect(layer.getRenderer().container.style.backgroundColor).to.be(
'rgba(0, 0, 255, 0.5)'
);
+ map.renderSync();
+ expect(layer.getRenderer().container.style.backgroundColor).to.be('');
done();
});
}); The patch would look like this; --- src/ol/renderer/canvas/Layer.js
+++ src/ol/renderer/canvas/Layer.js
@@ -195,12 +195,8 @@ class CanvasLayerRenderer extends LayerRenderer {
this.container = container;
this.context = context;
}
- if (
- !this.containerReused &&
- backgroundColor &&
- !this.container.style.backgroundColor
- ) {
- this.container.style.backgroundColor = backgroundColor;
+ if (!this.containerReused && this.container && this.container.style) {
+ this.container.style.backgroundColor = backgroundColor || null;
}
}
|
Thanks for your attempt to fix this, @kikuchan. The solution you chose changes the behavior in the case where multiple layers in the layer stack have a |
c17d60e
to
c7b5ad0
Compare
Thank you for your reply! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks for your continued effort! I added one minor suggestion, which you might want to consider.
Thank you for the suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks @kikuchan!
Thank you! |
Try to fix #14894