Hello I have created cesium window with the following code
<div id="cesiumContainer"></div>
function RenderCesium() {
var cesiumElem = new Cesium.Viewer('cesiumContainer');
}
I am not saving the cesiumElem above. I want to later access this Cesium element through another function. Is there a way to access this element later. I tried the below function. But when I am adding the entity, it gives an error. Please note that I do not want to make cesiumElem as a global variable.
function RenderEntity() {
var cesiumContainer = document.getElementById("cesiumContainer").;
cesiumContainer.entities.add({
position: Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label: {
text: "Philadelphia",
},
});
}
Thanks
Libish