onAdd()

in public/assets/maplibre/maplibre-custom-controls.js [35:65]


    onAdd(map) {
        this._map = map;
        this._container = document.createElement('div');
        this._container.className = 'maplibregl-ctrl maplibregl-ctrl-group';
        // Add button to the container
        this._button = document.createElement('button');
        this._button.type = 'button';
        this._button.className = 'maplibregl-ctrl-icon maplibregl-ctrl-split-view';
        // Toggle the split view
        this._button.onclick = () => {
            const splitMapContainer = document.getElementById(this._splitMapContainerId);
            const state = splitMapContainer.getAttribute('data-state');
            if (state === 'visible') {
                // Hide the osm map
                splitMapContainer.setAttribute('data-state', 'hidden');
                splitMapContainer.style.flex = '0';
                this._map.resize();
                this._splitMap.resize();
                this._button.style.backgroundColor = '';
            } else {
                // Show the osm map
                splitMapContainer.setAttribute('data-state', 'visible');
                splitMapContainer.style.flex = '1';
                this._map.resize();
                this._splitMap.resize();
                this._button.style.backgroundColor = 'rgb(0 0 0/20%)';
            }
        };
        this._container.appendChild(this._button);
        return this._container;
    }