Using ToggleButtonViewModel

I’ve “found” ToggleButtonViewModel while reading the documentation.

I could not find any example of how to use this.

Can anyone shed some light on this?


Yes, what exactly are you trying to do?

I've created buttons for my Cesium app, and they work fine (I create an
HTML element, and use an onclick event - the simple way :)). Just been
wondering if this can be of any use while creating my own buttons, and if
so, how?
I can see it's possible to send a callback function - just how do I "hook"
it to an actual button? Is it meant for this purpose?

OK, I think I get what you’re saying. So you want one of your own buttons to mimic the behavior of a Cesium Button?

So I actually looked into this yesterday and I believe you can do it - the only way I’m aware of is by using Dojo.

Here’s an example where they’re requiring the dependencies, then declaring the constructors that your own function will inherit from.

require([ ``"dojo/_base/declare"``, ``"dijit/_WidgetBase"``, ``"dijit/_TemplatedMixin" ], ``function``(declare, _WidgetBase, _TemplatedMixin){

``// "declare" holds the dojo declare function

``// "_WidgetBase" holds the dijit _WidgetBase constructor

``// "_TemplatedMixin" holds the dijit _TemplatedMixin constructor

``// Do whatever you want with these modules here.


What I ended up doing instead was creating new Cesium.Button 's, placing them and styling them in a way that made sense for the app.

So ya, I’m not sure of any other way to inherit all that behavior and those dependencies other than via require / define.

The ToggleButtonViewModel is a Knockout view model used internally in Cesium. It’s probably not useful in its current form externally, since it doesn’t really provide any functionality. It’s largely a leftover remnant of old code.

In general, Cesium does not require any particular UI framework. We use Knockout internally for our widgets, but you can use whatever framework you like, Dojo, jQueryUI, or no framework, as you’ve done. There is no Cesium-specific button system to integrate with. You simply create whatever HTML-based UI you want for your application and position it with CSS over top of the Cesium canvas.