SkylineGlobe TEPro 6.6.1 二次开发导出KML或者KMZ文件示例代码

其实Skyline的fly文件跟kml文件很像很像,只不过一个是编码加密的,另一个早已经成为OGC的通用标准;

喜欢Skyline的小伙伴们试试下面的代码吧,细心的人能发现彩蛋哦。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <script type="text/javascript" language="javascript">
        function ExportKML()
        {
            $("result").innerText = "";
            var sg = CreateSGObj();
            var objid = sg.ProjectTree.GetNextItem(sg.ProjectTree.RootID, 10);
            if (sg.ProjectTree.IsGroup(objid))
            {
                var kmlpath = sg.ProjectTree.SaveAsKml(sg.ProjectTree.GetItemName(objid) + ".kml", objid);
                //如果不指定kml文件后缀名,则导出的是kmz文件
                $("result").innerText = kmlpath;
            }
        }
        /*  
        功能:   创建sgworld对象
        备注:   赵贺 2015.06.23.
        */
        function CreateSGObj() {
            var obj = $("sgworld");
            if (obj == null) {
                obj = document.createElement('object');
                document.body.appendChild(obj);
                obj.name = "sgworld";
                obj.id = "sgworld";
                obj.classid = "CLSID:3A4F9199-65a8-11d5-85c1-0001023952c1";
            }
            return obj;
        }
        function $(id) {
            return window.document.getElementById(id);
        }
    </script>
</head>
<body>
    <table>        
        <tr>
            <td colspan="4">                
                <input id="btnExportKML" type="button" value="选择组导出KML" onclick="ExportKML()" />
            </td>
        </tr>
        <tr>
            <td>
                <div id="result">
                </div>
            </td>
        </tr>
    </table>
     <object id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" style="width:500px;height:400px;"></object>
    <object id="TerraExplorerInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" style="width:300px;height:400px;"></object>
</body>
</html>

 

posted @ 2016-10-10 11:02  依尔根觉罗天赫  阅读(1533)  评论(1)    收藏  举报