In C#, GLG drawing is deployed via the GLG C# Control. The SetDrawingObject is a method of the control that assigns the drawing to the parent control that will display the drawing.
There is no equivalent JavaScript Control in the HTML5 environment. Instead, the SetParentElement method of the drawing viewport is used to assign a parent HTML element to the drawing. The drawing will be displayed inside this parent HTML element.
The following is a sequence of calls used in the JavaScript to display a GLG drawing:
1. A GLG drawing is loaded asynchronously using the LoadWidgetFromURL method, specifying the drawing URL and the load callback (LoadCB) to be invoked when the drawing is ready, for example:
GLG.LoadWidgetFromURL( "mydrawing.g", null, LoadCB, user_data );
2. When the drawing is ready, the LoadCB callback is invoked with an object ID of the loaded drawing viewport. The following methods are invoked inside the callback to display the drawing:
// Assign a parent HTML element to the drawing.
drawing.SetParentElement( "glg_area" );
// Display the drawing.
drawing.InitialDraw();
Alternatevely, the SetupHierarchy and Update methods may be used instead of InitialDraw:
// Display the drawing.
drawing.SetupHierarchy();
drawing.Update();
The source code at the following link provides an example of using a GLG drawing on a web page:
More source code examples are provided in the examples_html5 directory of the GLG download.