码迷,mamicode.com
首页 > 其他好文 > 详细

SkylineGlobe 如何实现二次开发加载KML文件

时间:2014-12-11 18:45:05      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   for   java   

示例代码如下:

<!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>
    <script type="text/javascript" language="javascript">
        function LoadKML() {
            try {
                var sg = CreateSGObj();
                var kmlLayer = sg.Creator.CreateKMLLayer(abspath()+"/Binoculars.kml","");                
            }
            catch (e) {
                alert(e);
            }
        }
        
        /*  
        功能:   创建sgworld对象
        备注:   赵贺 2011.04.01.
        */

        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:3a4f9197-65a8-11d5-85c1-0001023952c1";
            }
            return obj;
        }
        function $(id) {
            return window.document.getElementById(id);
        }

        //--------------
        // abspath
        function abspath() {
            var abspath = unescape(window.location.href);

            // Remove query String 
            var index = abspath.indexOf("?");
            if (index > 0) abspath = abspath.substr(0, index - 1);

            index = abspath.lastIndexOf("/");
            var index2 = abspath.lastIndexOf("\\");

            index = (index > index2) ? index : index2;
            if (index <= 0) return abspath;

            abspath = abspath.substring(0, index);

            if (abspath.substring(0, 1) == "/") abspath = abspath.slice(1);

            var re = /file:\/\/\//gi;
            if (abspath.match(re) != null) abspath = abspath.replace(re, ""); // if this is indeed a local file, we strip the "file://" prefix from it.    

            return (abspath);
        }
    </script>
</head>
<body >
    <input id="Button1" type="button" value="加载KML" onclick="LoadKML()" />
    <object id="TE3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" width="1000px"
        height="600px">
    </object>
    <OBJECT ID="TerraExplorerInformationWindow" CLASSID="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" width="200px"
        height="600px" ></OBJECT>
</body>
</html>

 

SkylineGlobe 如何实现二次开发加载KML文件

标签:style   blog   http   io   ar   color   sp   for   java   

原文地址:http://www.cnblogs.com/yitianhe/p/4158089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!