1.创建组:
<html>
<head>
<title>Node 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0,0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Vermont" );
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0,0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Maine" );
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0,0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Massachusetts" );
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0,0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Rhode Island" );
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0,0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Connecticut" );
SGWorld.Navigate.FlyTo(Vermont);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample");
popup.InnerText = "This sample shows how to group several nodes - locations in this case,\n" +
"and add them to the SkylineGlobe nodes hierarchy.";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
<head>
<title>Node 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0,0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Vermont" );
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0,0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Maine" );
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0,0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Massachusetts" );
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0,0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Rhode Island" );
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0,0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland , "Connecticut" );
SGWorld.Navigate.FlyTo(Vermont);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample");
popup.InnerText = "This sample shows how to group several nodes - locations in this case,\n" +
"and add them to the SkylineGlobe nodes hierarchy.";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
2.对象数据:
<html>
<head>
<title>Node 2</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
var newEnglandPopulation =
parseInt(Vermont.ClientData("population")) +
parseInt(Maine.ClientData("population")) +
parseInt(Massachusetts.ClientData("population")) +
parseInt(RhodeIsland.ClientData("population")) +
parseInt(Connecticut.ClientData("population"));
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample");
popup.InnerHTML = "This sample shows how to set and retrieve attribute information to a object.<br><br>" +
"The total population of <b>New England</b> in 1990 was: " + newEnglandPopulation;
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
<head>
<title>Node 2</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
var newEnglandPopulation =
parseInt(Vermont.ClientData("population")) +
parseInt(Maine.ClientData("population")) +
parseInt(Massachusetts.ClientData("population")) +
parseInt(RhodeIsland.ClientData("population")) +
parseInt(Connecticut.ClientData("population"));
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample");
popup.InnerHTML = "This sample shows how to set and retrieve attribute information to a object.<br><br>" +
"The total population of <b>New England</b> in 1990 was: " + newEnglandPopulation;
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
3.遍历对象:
<html>
<head>
<title>Node 3</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var group = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample","",0,0,400,200);
popup.InnerHTML = "This sample shows how to traverse the node hierarchy.<br><br>";
// 11 is get child
var node = SGWorld.ProjectTree.GetNextItem(group, 11);
while (node > 0)
{
var object = SGWorld.ProjectTree.GetObject(node);
popup.innerHTML += "The population of <b>" + object.TreeItem.Name + "</b> is: " + object.ClientData("population") + "<br>";
// 13 is get next sibling
node = SGWorld.ProjectTree.GetNextItem(node, 13);
}
popup.align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
<head>
<title>Node 3</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
var group = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample","",0,0,400,200);
popup.InnerHTML = "This sample shows how to traverse the node hierarchy.<br><br>";
// 11 is get child
var node = SGWorld.ProjectTree.GetNextItem(group, 11);
while (node > 0)
{
var object = SGWorld.ProjectTree.GetObject(node);
popup.innerHTML += "The population of <b>" + object.TreeItem.Name + "</b> is: " + object.ClientData("population") + "<br>";
// 13 is get next sibling
node = SGWorld.ProjectTree.GetNextItem(node, 13);
}
popup.align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
4.搜索树节点:
<html>
<head>
<title>Node 5</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// Create the "New England" group node and its children
var NewEngland = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample","",0,0,350,150);
popup.InnerHTML = "This sample shows how to search the nodes heirarchy tree.<br><br>";
popup.InnerHTML += "<b><u>Search Results:</u></b><br>";
var RhodeIsland = SGWorld.ProjectTree.FindItem("\\New England\\Rhode Island");
if (RhodeIsland > 0)
popup.InnerHTML += "The population of <b>Rhode Island</b> is: " + SGWorld.ProjectTree.GetObject(RhodeIsland).ClientData("population") + "<br>";
popup.align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
<head>
<title>Node 5</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// Create the "New England" group node and its children
var NewEngland = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample","",0,0,350,150);
popup.InnerHTML = "This sample shows how to search the nodes heirarchy tree.<br><br>";
popup.InnerHTML += "<b><u>Search Results:</u></b><br>";
var RhodeIsland = SGWorld.ProjectTree.FindItem("\\New England\\Rhode Island");
if (RhodeIsland > 0)
popup.InnerHTML += "The population of <b>Rhode Island</b> is: " + SGWorld.ProjectTree.GetObject(RhodeIsland).ClientData("population") + "<br>";
popup.align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
5.删除树节点:
<html>
<head>
<title>Node 7</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// Create the "New England" group node and its children
var NewEngland = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample", "", 0, 0, 350, 150);
popup.InnerText = "This sample shows how to remove (delete) nodes.";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
setTimeout(DeleteObjects, 100);
}
function DeleteObjects()
{
alert("Click OK to remove Maine and Vermont from the New England group");
var nodeToDelete = SGWorld.ProjectTree.FindItem("\\New England\\Maine");
SGWorld.ProjectTree.DeleteItem(nodeToDelete);
nodeToDelete = SGWorld.ProjectTree.FindItem("\\New England\\Vermont");
SGWorld.ProjectTree.DeleteItem(nodeToDelete);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
<head>
<title>Node 7</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// Create the "New England" group node and its children
var NewEngland = createNewEnglandNode();
popup = SGWorld.Creator.CreatePopupMessage("Nodes hierarchy sample", "", 0, 0, 350, 150);
popup.InnerText = "This sample shows how to remove (delete) nodes.";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
setTimeout(DeleteObjects, 100);
}
function DeleteObjects()
{
alert("Click OK to remove Maine and Vermont from the New England group");
var nodeToDelete = SGWorld.ProjectTree.FindItem("\\New England\\Maine");
SGWorld.ProjectTree.DeleteItem(nodeToDelete);
nodeToDelete = SGWorld.ProjectTree.FindItem("\\New England\\Vermont");
SGWorld.ProjectTree.DeleteItem(nodeToDelete);
}
function createNewEnglandNode()
{
var NewEngland = SGWorld.ProjectTree.CreateGroup("New England");
var Vermont = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.75206, 43.91127, 0, 0, 0.0, 0, -85, 800000.0), "Vermont", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Vermont");
var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-69.40414, 45.12594, 0, 0, 0.0, 0, -85, 800000.0), "Maine", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Maine");
var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.88455, 42.34216, 0, 0, 0.0, 0, -85, 800000.0), "Massachusetts", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Massachusetts");
var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.57073, 41.62953, 0, 0, 0.0, 0, -85, 800000.0), "Rhode Island", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Rhode Island");
var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-72.64295, 41.57912, 0, 0, 0.0, 0, -85, 800000.0), "Connecticut", SGWorld.Creator.CreateLabelStyle(), NewEngland, "Connecticut");
SGWorld.Navigate.FlyTo(Vermont);
// setting attributes to the nodes
Vermont.ClientData("population") = 562758;
Maine.ClientData("population") = 1227928;
Massachusetts.ClientData("population") = 6016425;
RhodeIsland.ClientData("population") = 1003464;
Connecticut.ClientData("population") = 3287116;
return NewEngland;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
SGWorld.ProjectTree.DeleteItem(SGWorld.ProjectTree.FindItem("New England"));
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>