@carto/airship-bridge
Version:
Airship bridge to other libs (CARTO VL, CARTO.js)
24 lines (23 loc) • 874 B
JavaScript
import { select } from '../../util/Utils';
var Layers = /** @class */ (function () {
function Layers(layersSelector, carto, layers, mapLayers) {
this._layersSelector = select(layersSelector);
this._carto = carto;
this._layers = layers;
this._mapLayers = mapLayers;
}
Layers.prototype.build = function () {
var _this = this;
this._carto.on('loaded', this._mapLayers, function () {
_this._layersSelector.layers = _this._layers;
_this._layersSelector.forceUpdate();
_this._layersSelector.addEventListener('onToggleLayer', function (evt) {
var layer = _this._mapLayers[evt.detail.index];
var toggle = layer.visible ? 'hide' : 'show';
layer[toggle]();
});
});
};
return Layers;
}());
export default Layers;