const ISSLayer = { _viewer: null, _entity: null, _interval: null, _count: 0, start(viewer) { if (this._entity) return; this._viewer = viewer; this._entity = viewer.entities.add({ name: 'ISS - International Space Station', position: Cesium.Cartesian3.fromDegrees(0, 0, 420000), point: { pixelSize: 18, color: Cesium.Color.fromCssColorString('#ff4444'), outlineColor: Cesium.Color.WHITE, outlineWidth: 2 }, label: { text: 'ISS', font: '12px monospace bold', fillColor: Cesium.Color.fromCssColorString('#ff4444'), outlineColor: Cesium.Color.BLACK, outlineWidth: 3, style: Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new Cesium.Cartesian2(12, -6) }, description: '
International Space Station
Hoehe: ~420 km
Geschwindigkeit: ~27.600 km/h
', }); this._count = 1; this._fetch(); var self = this; this._interval = setInterval(function() { self._fetch(); }, 5000); }, stop() { if (this._interval) { clearInterval(this._interval); this._interval = null; } if (this._entity && this._viewer) { this._viewer.entities.remove(this._entity); this._entity = null; } this._count = 0; }, _fetch() { var self = this; fetch('/api/iss') .then(function(r) { return r.json(); }) .then(function(data) { if (!self._entity || data.message !== 'success') return; var pos = data.iss_position; self._entity.position = Cesium.Cartesian3.fromDegrees( parseFloat(pos.longitude), parseFloat(pos.latitude), 420000 ); }).catch(function() {}); }, };