Prevent ol.css being added multiple times

Signed-off-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
This commit is contained in:
Liviu-Mihail Concioiu 2025-04-30 19:23:30 +02:00
parent 9db0f07ecc
commit c3266c2c52

View File

@ -434,7 +434,13 @@ class GisVisualization
$output = 'function drawOpenLayers() {'
. 'if (typeof ol !== "undefined") {'
. 'var olCss = "js/vendor/openlayers/theme/ol.css";'
. '$(\'head\').append(\'<link rel="stylesheet" type="text/css" href=\'+olCss+\'>\');'
. 'if (!document.querySelector(\'link[rel="stylesheet"][href="\' + olCss + \'"]\')) {'
. 'var link = document.createElement(\'link\');'
. 'link.rel = \'stylesheet\';'
. 'link.type = \'text/css\';'
. 'link.href = olCss;'
. 'document.head.appendChild(link);'
. '}'
. 'var vectorLayer = new ol.source.Vector({});'
. 'var map = new ol.Map({'
. 'target: \'openlayersmap\','