createMessage Method

Creates an object that defines content (e.g., HTML or simple text) that is displayed to the user when a certain events fire.

createMessage(msgData, msgType, msgClient);

 

Parameter

Description

msgData

The content of the message. This parameter is interpreted according to the msgType parameter.

Can be a string , SGPopup or SGNotification object

msgType

The message type

Can be one of the following: sgMessageTypeText, sgMessageTypeURL, sgMessageTypeScript

msgClient

The destination client of the message object

Can be one of the following: sgMessageClientPopup , sgMessageClientFloatBrowser, sgMessageClientUpperLeft, sgMessageClientLowerLeft, sgMessageClientMain, sgMessageClientMessageBar, ,

Return Value

An SGNode object. If the method fails, the return value is null. SGWorld.lastError will contain the failure reason.

Remarks

To modify other properties of the message, access the node innerObj. See SGNode.innerObj property and ITerraExplorerMessage5 interface for more details.

The message is triggered when the user clicks on an object that is associated with that message object. When a message object is triggered, the message content is displayed in the message-defined client. Usually after creating a message object, the client associates it with a node object by calling SGNode.setMessage, passing the newly created message object as the method argument. Several different objects can be associated with the same message object at the same time.

The following values, available for the msgClient parameter, do not have visual representation while working with the Skyline Globe Control: sgMessageClientUpperLeft, sgMessageClientLowerLeft, sgMessageClientMain, sgMessageClientMessageBar.

They only take effect when working with the stand alone TerraExplorer product.

Example

The following example illustrates the use of the createMessage method.

 

function createMessage()

{

   var message = globe.creator.createMessage(

                 "http://www.yahoo.com",

                 sgMessageTypeURL,

                 sgMessageClientFloatBrowser

                 );

 

   var label = globe.creator.createTextLabel(

               new SGCoord3D(-122.41519, 37.74346, 50),

               "Click Me"

               );

 

   label.setMessage(message);

 

   globe.root.appendChild(label);

 

   globe.navigate.flyTo(label);

}