Avoid failure if existing target has no background color
This commit is contained in:
@@ -114,10 +114,11 @@ class CanvasLayerRenderer extends LayerRenderer {
|
|||||||
target.style.opacity === '' &&
|
target.style.opacity === '' &&
|
||||||
opacity === 1 &&
|
opacity === 1 &&
|
||||||
(!opt_backgroundColor ||
|
(!opt_backgroundColor ||
|
||||||
|
(target.style.backgroundColor &&
|
||||||
equals(
|
equals(
|
||||||
asArray(target.style.backgroundColor),
|
asArray(target.style.backgroundColor),
|
||||||
asArray(opt_backgroundColor)
|
asArray(opt_backgroundColor)
|
||||||
))
|
)))
|
||||||
) {
|
) {
|
||||||
const canvas = target.firstElementChild;
|
const canvas = target.firstElementChild;
|
||||||
if (canvas instanceof HTMLCanvasElement) {
|
if (canvas instanceof HTMLCanvasElement) {
|
||||||
|
|||||||
BIN
test/rendering/cases/layer-vector-background-over/expected.png
Normal file
BIN
test/rendering/cases/layer-vector-background-over/expected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
41
test/rendering/cases/layer-vector-background-over/main.js
Normal file
41
test/rendering/cases/layer-vector-background-over/main.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import GeoJSON from '../../../../src/ol/format/GeoJSON.js';
|
||||||
|
import Map from '../../../../src/ol/Map.js';
|
||||||
|
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
||||||
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
|
import View from '../../../../src/ol/View.js';
|
||||||
|
import XYZ from '../../../../src/ol/source/XYZ.js';
|
||||||
|
import {Fill, Stroke, Style} from '../../../../src/ol/style.js';
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 1,
|
||||||
|
}),
|
||||||
|
layers: [
|
||||||
|
new TileLayer({
|
||||||
|
source: new XYZ({
|
||||||
|
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg',
|
||||||
|
transition: 0,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
new VectorLayer({
|
||||||
|
background: '#a9d3df',
|
||||||
|
source: new VectorSource({
|
||||||
|
url: '/data/countries.json',
|
||||||
|
format: new GeoJSON(),
|
||||||
|
}),
|
||||||
|
style: new Style({
|
||||||
|
stroke: new Stroke({
|
||||||
|
color: '#ccc',
|
||||||
|
}),
|
||||||
|
fill: new Fill({
|
||||||
|
color: 'white',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
Reference in New Issue
Block a user