Skip to content

Commit

Permalink
Changed adding buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyblasta committed Jul 19, 2022
1 parent 9f9ce6d commit 949c5f3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/controls/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,12 @@ const Legend = function Legend(options = {}) {
restoreState(params);
},
getuseGroupIndication() { return useGroupIndication; },
addButtonToTools(button, addDiveder = true) {
addButtonToTools(button) {
const toolsEl = document.getElementById(toolsCmp.getId());
toolsEl.classList.remove('hidden');
if (toolsCmp.getComponents().length > 0) {
toolsEl.style.justifyContent = 'right';
if (addDiveder) {
toolsEl.insertBefore(dom.html(divider.render()), toolsEl.firstChild);
}
toolsEl.style.justifyContent = 'space-between';
toolsEl.insertBefore(dom.html(divider.render()), toolsEl.firstChild);
toolsEl.insertBefore(dom.html(button.render()), toolsEl.firstChild);
} else {
toolsEl.appendChild(dom.html(button.render()));
Expand Down Expand Up @@ -489,6 +487,14 @@ const Legend = function Legend(options = {}) {
viewer.getMap().on('click', onMapClick);
},
onRender() {
const layerControlCmps = [];
if (searchLayersControl) layerControlCmps.push(layerSearchInput);
if (turnOnLayersControl) layerControlCmps.push(turnOnLayersButton);
if (turnOffLayersControl) layerControlCmps.push(turnOffLayersButton);
const layerControl = El({
cls: 'grow flex justify-end align-center no-shrink',
components: layerControlCmps
});
mainContainerEl = document.getElementById(mainContainerCmp.getId());
layerButtonEl = document.getElementById(layerButton.getId());
layerSwitcherEl.addEventListener('collapse:toggle', (e) => {
Expand All @@ -497,9 +503,7 @@ const Legend = function Legend(options = {}) {
toggleVisibility();
});
window.addEventListener('resize', updateMaxHeight);
if (turnOffLayersControl) this.addButtonToTools(turnOffLayersButton, false);
if (turnOnLayersControl) this.addButtonToTools(turnOnLayersButton, false);
if (searchLayersControl) this.addButtonToTools(layerSearchInput);
if (layerControlCmps.length > 0) this.addButtonToTools(layerControl);
initAutocomplete();
bindUIActions();
setTabIndex();
Expand Down

0 comments on commit 949c5f3

Please sign in to comment.