There are many events in the skyline that can be called. Today I will introduce you to several commonly used events.
1. Open ()
Open the specified project
//初始化加载TerraExplorer工程 $(window).load(function() { try { var flyPath = "C:\\Users\\admin\\Desktop\\SkyglobeLB.fly"; sgworld.AttachEvent("OnLoadFinished", OnProjectLoadFinished); sgworld.Project.Open(flyPath); } catch(ex) { addLog(ex.message); } });
二、OnProjectLoadFinished()
After we execute the Open method of SGWorld, after loading a FLY project, this event will be triggered.
In other words, we can use this event to determine when the loading of the FLY project has been completed, and then we can say a "Hello World!" A place, turn on or turn off certain layers, etc.
// load event function OnProjectLoadFinished () { // the default fly to a certain location var Washington = sgworld.Creator.CreatePosition ( 116.3912630081 , 39.9074812817 , 1000 , 0 , 0.0, // yaw angle -43.0); // pitch angle sgworld .Navigate.FlyTo (Washington); alert ( "Hello World!" ); }
Three, OnFrame ()
Send events before frames are rendered, allowing clients to perform operations in frame motion (for example, moving ground objects). Every frame movement will trigger this method.
// Add event sgworld.AttachEvent ("OnFrame" , OnFrame); // Call function OnFrame () { if (lable! = Null ) { lable.Position = lable.Position.Move (100, -90, $ (" #pitch " ) .val ()); } }
Four, OnLButtonClicked ()
Fires when the user clicks the left mouse button
// Register left mouse click event sgworld.AttachEvent ("OnLButtonClicked" , OnLButtonClicked); // Left mouse click event function OnLButtonClicked (Flags, X, Y) { alert (Flags + "===" + X + "= == "+ Y); } // Flags, define various key combinations to be pressed, / * MK_LBUTTON = 1 MK_RBUTTON = 2 MK_SHIFT = 4 MK_CONTROL = 8 MK_MBUTTON = 16 * / // X, X coordinate of the mouse. The coordinates are screen coordinates, and the upper left corner of the 3D window is the starting coordinate // Y, the Y coordinate of the mouse. Coordinates are screen coordinates, and the upper left corner of the 3D window is the starting coordinate
Five, OnLButtonDblClk ()
The event is triggered when the user double-clicks the left mouse button
And four, OnLButtonClicked () similar
六 、 OnLButtonDown ()
The event is triggered when the user presses the left mouse button
And four, OnLButtonClicked () similar
Seven, OnLButtonUp ()
The event is triggered when the user releases the left mouse button
And four, OnLButtonClicked () similar
Eight, OnMButtonDblClk ()
The event is triggered when the user double-clicks the middle mouse button
And four, OnLButtonClicked () similar
九 、 OnMButtonDown ()
The event is triggered when the user presses the middle mouse button
And four, OnLButtonClicked () similar
Ten, OnMButtonUp ()
The event is triggered when the user releases the middle mouse button
And four, OnLButtonClicked () similar