const CablesLayer = { _viewer: null, _dataSource: null, _count: 0, start(viewer) { if (this._dataSource) return; this._viewer = viewer; this._dataSource = new Cesium.GeoJsonDataSource('cables'); this._fetch(); }, stop() { if (this._dataSource && this._viewer) { this._viewer.dataSources.remove(this._dataSource); this._dataSource = null; } this._count = 0; }, _fetch() { var self = this; var statusEl = document.getElementById('status-cables'); if (statusEl) { statusEl.textContent = 'Lade Seekabel...'; statusEl.classList.add('active'); } fetch('/api/submarine-cables') .then(function(r) { return r.json(); }) .then(function(data) { self._count = (data.features || []).length; return self._dataSource.load(data, { stroke: Cesium.Color.fromCssColorString('#00ccff').withAlpha(0.4), strokeWidth: 1.5, clampToGround: true, }); }) .then(function() { self._viewer.dataSources.add(self._dataSource); if (statusEl) statusEl.textContent = self._count + ' Kabel'; }) .catch(function(e) { console.warn('Cables:', e); if (statusEl) statusEl.textContent = 'Fehler'; }) .finally(function() { setTimeout(function() { if (statusEl) statusEl.classList.remove('active'); }, 5000); }); }, };