From c947c6749ff32d9fb383901322efda19330c7721 Mon Sep 17 00:00:00 2001 From: f-necas <39771412+f-necas@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:22:01 +0100 Subject: [PATCH] backport: avoid race condition, resize map once target size ok (#270) --- .../components/common/openlayers/olMapDirective.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web-ui/src/main/resources/catalog/components/common/openlayers/olMapDirective.js b/web-ui/src/main/resources/catalog/components/common/openlayers/olMapDirective.js index d3a831bd21..0ff7a5bc36 100644 --- a/web-ui/src/main/resources/catalog/components/common/openlayers/olMapDirective.js +++ b/web-ui/src/main/resources/catalog/components/common/openlayers/olMapDirective.js @@ -58,7 +58,15 @@ var prop = attrs[attr]; var map = scope.$eval(prop); - map.setTarget(element[0]); + var target = element[0]; + + var resizeObserver = new ResizeObserver(function() { + map.updateSize(); + resizeObserver.unobserve(target); + }); + + map.setTarget(target); + resizeObserver.observe(target); } }; };