1. A concise explanation of the problem you’re experiencing.
Hello, I need to add some ToggleButtons to my toolbar menu.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
// ToggleButton I use normally.
Sandcastle.addToggleButton(
’ Enable light’,
viewer.scene.globe.enableLighting,
function(checked) {
viewer.scene.globe.enableLighting = checked;
}
);
//ToolbarMenu where I want to add my ToggleButton.
Sandcastle.addToolbarMenu([{
text : ‘This should be replaced with a ToggleButton’,
}], ‘toolbar’);
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to create a kind of DropDownList with checkboxes (ToggleButtons). Is there any way? Thanks in advance.
4. The Cesium version you’re using, your operating system and browser.
CesiumJS 1.60
Windows 7
Mozilla Firefox 68.0.2
omar
August 29, 2019, 5:23pm
2
This Sandcastle has an example of toggle buttons:
https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Shadows.html
Note that this works in Sandcastle, because of the additional helper functions there, but wouldn’t work in a web app that just includes the CesiumJS library.
Thanks for your reply. I need to add CheckBoxes in the DropDownList.
So I can open the list by clicking it, select the ToggleButtons and then close the list.
Is it possible? Thanks.
omar
September 3, 2019, 2:21pm
4
You should be able to create any HTML UI you need and just listen for changes to that. There’s nothing specific or unique to CesiumJS there. For example this Stackoverflow answer has some suggestions on doing this:
https://stackoverflow.com/questions/19206919/how-to-create-checkbox-inside-dropdown
And then you can have that affect your CesiumJS scene when the selection is made.