From defb6875d7826a9a2412b03dd04be5dbb3317a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sat, 20 Aug 2022 11:21:44 +0200 Subject: [PATCH] Sync form state with map on load --- examples/reprojection-by-code.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/reprojection-by-code.js b/examples/reprojection-by-code.js index 2e169c1340..0e92582e2b 100644 --- a/examples/reprojection-by-code.js +++ b/examples/reprojection-by-code.js @@ -139,12 +139,19 @@ searchButton.onclick = function (event) { /** * Handle checkbox change events. */ -renderEdgesCheckbox.onchange = function () { +function onReprojectionChange() { osmSource.setRenderReprojectionEdges(renderEdgesCheckbox.checked); -}; -showTilesCheckbox.onchange = function () { - debugLayer.setVisible(showTilesCheckbox.checked); -}; -showGraticuleCheckbox.onchange = function () { +} +function onGraticuleChange() { graticule.setVisible(showGraticuleCheckbox.checked); -}; +} +function onTilesChange() { + debugLayer.setVisible(showTilesCheckbox.checked); +} +showGraticuleCheckbox.addEventListener('change', onGraticuleChange); +renderEdgesCheckbox.addEventListener('change', onReprojectionChange); +showTilesCheckbox.addEventListener('change', onTilesChange); + +onReprojectionChange(); +onGraticuleChange(); +onTilesChange();