Reputation: 678
So I am working on customizing a Cesium map by displaying markers in various positions based on JSON data fetched from another server. One of the things I want to do is to create an accordion-like div element to hold a list of strings that can be toggled on and off (to hide the data if it is too long).
However, Cesium refuses to run my code inside the entity description. I have tested the code with a simple function:
html += "<small onclick='test();'>[\u2212]</small>";
...
html += "<script>function test() { console.log('bob'); }<\/script>";
jsonData.description = html; // The Cesium CZML JSON entity
However, running the code throws a function not defined
error in the console, even when I allow scripts to run via
mapViewer.infoBox.frame.sandbox = "allow-same-origin allow-popups allow-forms allow-scripts allow-top-navigation";
My question is this: is there something I am doing wrong here? I know Cesium loads the entity description HTML code in a sandboxed iframe, but I should be allowing scripts to run in the sandbox. I have also tried putting the test()
function outside of the description, but I still run into the same error.
Any help would be highly appreciated.
Upvotes: 1
Views: 1031
Reputation: 2311
It is currently not supported. There's a PR for this: https://github.com/AnalyticalGraphicsInc/cesium/pull/5764
Hopefully it would be approved sometime soon.
Upvotes: 0