Hello, I'm trying to improve the InfoBox of my cesium development (http://social4d.com/) and I'm finding to do something like that https://cesiumjs.org/d3cesium/ where you can see how into the infobox is showed the interpolate number of height of the polyline in each moment. I'm trying to adapt this code to my web, but the problem is that I have no idea about how I can change the infobox because cesium doesn't have any function to modify it, not?
In this moment I'm reading the documentation about the InfoBox but doesn't appear nothing about modify the content. Do you have any idea?
Ok, I found the method to modify the InfoBox of one entity:
entity.description = "Hello";
But I want insert in the description one value of the entity that is changing with the time (the height of extrusion of a polygon). I found the function getValue(time) but, I have no idea about where is declared the variable time in function. Any help?
In my opinion, the documentation of Cesium is very very well, but one example from each function would help all the doubts...
In order to run a script in the infobox, you have to enable scrips to run in the iframe. This is disabled by default for security reasons, in case you don’t know the source of the data populating the infobox.
You can enable scrips with this code:
var iframe = document.getElementsByClassName(‘cesium-infoBox-iframe’)[0];
iframe.setAttribute(‘sandbox’, ‘allow-same-origin allow-scripts allow-popups allow-forms’);
Also, to get the current value of an entity property, you can use .getValue(viewer.clock.currentTime);
One thing you could do also is (we did this this), just completely get rid of the default info box and then listen for the selectedEntityChanged events within Cesium and show a custom info box using info from the selected entity
The viewer has a selectedEntityChanged event so you can listen for that, undo the default behavior (set viewer.selectedEntity = undefined) and then do your own custom behavior:
What he was looking for (I think) was the ability to show a button in the InfoBox and it run his custom JavaScript when clicked. The issue with that is though that, the InfoBox code is run in an iframe and isn’t in the same scope as his other code.
I’m not 100% sure if this is what Omar was suggesting or not but this is what we did with our tool. Using that selectedEntityChanged event, disable the default InfoBox component and watch that event. When an item is selected, show your own custom modal or other component/HTML that is within the same scope and not in the iframe previously mentioned. That way you have complete control over that piece and can style it to do exactly what you want it to do.