Skyline软件二次开发初级——8如何在WEB页面中的三维地图上管理信息树

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 >

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.7520643.91127000.00, - 85800000.0),  " Vermont ", SGWorld.Creator.CreateLabelStyle(), NewEngland,  " Vermont ");
             var Maine = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(- 69.4041445.12594000.00, - 85800000.0),  " Maine ", SGWorld.Creator.CreateLabelStyle(), NewEngland,  " Maine ");
             var Massachusetts = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(- 71.8845542.34216000.00, - 85800000.0),  " Massachusetts ", SGWorld.Creator.CreateLabelStyle(), NewEngland,  " Massachusetts ");
             var RhodeIsland = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(- 71.5707341.62953000.00, - 85800000.0),  " Rhode Island ", SGWorld.Creator.CreateLabelStyle(), NewEngland,  " Rhode Island ");
             var Connecticut = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(- 72.6429541.57912000.00, - 85800000.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 οnlοad= " Init(); " οnunlοad= " 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 >

 

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 >

 

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 >

 

转载于:https://www.cnblogs.com/yitianhe/archive/2012/09/24/2699672.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值