From 187a216379e1a319e32d89e41e7c97518717f25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 4 Oct 2020 19:01:45 +0200 Subject: [PATCH] Do not draw empty text styles This fixes a rendering/flicker issue when an empty text style is decluttered together with an image style. --- src/ol/renderer/vector.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ol/renderer/vector.js b/src/ol/renderer/vector.js index 0e01263ac0..7452b56b9e 100644 --- a/src/ol/renderer/vector.js +++ b/src/ol/renderer/vector.js @@ -82,7 +82,7 @@ function renderCircleGeometry( circleReplay.drawCircle(geometry, feature); } const textStyle = style.getText(); - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT @@ -251,7 +251,7 @@ function renderLineStringGeometry( lineStringReplay.drawLineString(geometry, feature); } const textStyle = style.getText(); - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT @@ -285,7 +285,7 @@ function renderMultiLineStringGeometry( lineStringReplay.drawMultiLineString(geometry, feature); } const textStyle = style.getText(); - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT @@ -320,7 +320,7 @@ function renderMultiPolygonGeometry( polygonReplay.drawMultiPolygon(geometry, feature); } const textStyle = style.getText(); - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT @@ -349,7 +349,8 @@ function renderPointGeometry( let sharedData; if (opt_declutterBuilderGroup) { builderGroup = opt_declutterBuilderGroup; - sharedData = imageStyle && textStyle ? {} : undefined; + sharedData = + imageStyle && textStyle && textStyle.getText() ? {} : undefined; } if (imageStyle) { if (imageStyle.getImageState() != ImageState.LOADED) { @@ -362,7 +363,7 @@ function renderPointGeometry( imageReplay.setImageStyle(imageStyle, sharedData); imageReplay.drawPoint(geometry, feature); } - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = builderGroup.getBuilder( style.getZIndex(), BuilderType.TEXT @@ -391,7 +392,8 @@ function renderMultiPointGeometry( let sharedData; if (opt_declutterBuilderGroup) { builderGroup = opt_declutterBuilderGroup; - sharedData = imageStyle && textStyle ? {} : undefined; + sharedData = + imageStyle && textStyle && textStyle.getText() ? {} : undefined; } if (imageStyle) { if (imageStyle.getImageState() != ImageState.LOADED) { @@ -404,7 +406,7 @@ function renderMultiPointGeometry( imageReplay.setImageStyle(imageStyle, sharedData); imageReplay.drawMultiPoint(geometry, feature); } - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT @@ -439,7 +441,7 @@ function renderPolygonGeometry( polygonReplay.drawPolygon(geometry, feature); } const textStyle = style.getText(); - if (textStyle) { + if (textStyle && textStyle.getText()) { const textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder( style.getZIndex(), BuilderType.TEXT