还是打不开我发布的场景,求指点

0 投票
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=8" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>三维管线展示</title>
        <script type="text/javascript" src="lib_Ajax/MicrosoftAjax.js"></script>
        <script type="text/javascript" src="lib_Ajax/echarts-all.js"></script>
        <script type="text/javascript" src="lib_Ajax/interface.js"></script>
        <script type="text/javascript" src="lib_Ajax/jquery.js"></script>
        <script type="text/javascript" src="lib_Ajax/SuperMap-7.0.1-11323.js"></script>
        <script type="text/javascript" src="lib_Realspace/SuperMap.Web.Realspace.js"></script>
        <script type="text/javascript" src="Scripts/GettingStarted.js"></script>

        <script type="text/javascript">
            var scene = null;
            var sceneControl = null;
            var htmlUrl = document.location.host;
            //判断网页的打开方式是本地打开还是通过网络打开
            //不同的打开方式url赋值不同
            if(htmlUrl == "")
            {
                htmlUrl = "http://localhost:8090";
            }
            else
            {
                htmlUrl = "http://" + htmlUrl;
            }
            var sceneUrl = htmlUrl + "/iserver/services/3D-Pipe/rest/realspace";

            function onPageLoad()
            {
                //初始化三维场景控件
                try
                {
                    //初始化三维场景控件实例,参数为包含控件的HTML元素
                    sceneControl = new SuperMap.Web.UI.Controls.SceneControl($get("sceneControlDiv"), initCallback, failedCallback);
                }
                catch(e)
                {
                    //若没有安装插件,则抛出该异常
                    if (e.name == SuperMap.Web.Realspace.ExceptionName.PlugInNotInstalled)
                    {
                        var url = htmlUrl + "/iserver/iClient/for3D/plugin/Setup.exe";
                        document.write("<a href='"+url+"'>未检测到 SuperMap iClient3D for  Plugin 插件,请单击此处下载并安装插件。</a>");
                        return;
                    }
                    //若使用非IE浏览器,则抛出该异常
                    else if (e.name == SuperMap.Web.Realspace.ExceptionName.BrowserNotSupport)
                    {
                        document.write("<p>SuperMap iClient3D for  Plugin 目前仅支持 InternetExplorer 浏览器,请更换浏览器后重新尝试加载本页面。</p>");
                        return;
                    }
                    //抛出其他异常
                    else
                    {
                        alert(e.message);
                    }

                }

            }

            //控件初始化完成后的回调函数,初始化完成之后才能进行数据加载
            function initCallback()
            {
                //获取Realspace控件的场景,控件和场景是一对一的捆绑关系
                scene = sceneControl.get_scene();

                //加载场景
                SceneLoad();

                //给选择事件注册回调函数,选择事件返回当前有选中对象的所有选择集,类型是选择集的数组
                sceneControl.addEvent("objectSelected", handler);

            }

            //控件初始化失败后的回调函数
            function failedCallback()
            {
                alert("Realspace initialized failed!");
            }

            //选择事件的回调函数,弹出选中对象的id
            function handler(selection3Ds)
            {
                //获取选择集的数目
                 var selection3DCount =  selection3Ds.length;
                 for(var i=0; i<selection3DCount; i++)
                 {
                      //获取选择集中被选中对象的数目
                      var selectCount = selection3Ds[i].get_count();
                      for(var j=0; j<selectCount; j++)
                      {
                          //获取选择集
                          var selection3D = selection3Ds[i];
                          var layer3D = scene.get_layer3Ds().get_item(selection3D.get_layer3D().get_name());
                          var selectObjectName = layer3D.findFeature3DByID(selection3D.get_item(j)).get_name();
                          alert(selection3D.get_item(j)+"\n"+selectObjectName);
                      }
                }

            }

            function SceneLoad()
            {
                //指定场景的服务器地址
                var sceneAddress = sceneUrl;

                //指定图层名称
                var sceneName = "scene";

                //打开场景
                scene.open(sceneAddress, sceneName);

                //获取场景中的图层
                var layer3D = scene.get_layer3Ds().get_item("Ground@OlympicGreen");
                if (layer3D != null)
                {
                    //获取图层的地理范围,并飞行到该范围
                    var geobound = layer3D.get_bounds();

                    scene.get_flyingOperator().flyToBounds(geobound);
                }

            }
            function viewEntire()
            {
                //全局显示整个三维场景
                scene.viewEntire();
            }
            function setPan()
            {
                //设置控件的当前操作为漫游
                var panAction = new SuperMap.Web.UI.Action3Ds.Pan(sceneControl);

                sceneControl.set_sceneAction(panAction);
            }
            function setSelect()
            {
                //设置控件的当前操作为选择
                var selectAction = new SuperMap.Web.UI.Action3Ds.Select(sceneControl);

                sceneControl.set_sceneAction(selectAction);
            }
            function refresh()
            {
                //刷新场景
                scene.refresh();
            }
        </script>
    </head>

    <body onLoad="onPageLoad()" >
        <div id="sceneControlDiv" style="position:absolute;margin:0;padding:0;border:1px solid black;z-index:1;left:0;width:100%;top:0;height:95%;visibility:visible;">
            <!--全幅显示-->
            <input id="viewentire" type="button" value="全幅显示" onClick="return viewEntire()" />

            <!--漫游-->
            <input id="pan" type="button" value="漫    游" onClick="return setPan()" />

            <!--选择-->
            <input id="select" type="button" value="选    择" onClick="return setSelect()" />

            <!--刷新-->
            <input id="refresh" type="button" value="刷    新" onClick="return refresh()" />
        </div>
    </body>
</html>
7月 10, 2017 分类:  578次浏览 | 用户: 胡利辉 (3 分)

1个回答

0 投票

您好,首先您要保证您发布的工作空间是什么格式,缓存工作空间(sxwu格式)、原始的工作空间(smwu格式),如果您发布的是smwu格式的原始工作空间,就必须在桌面里关掉,才能在浏览器查看。因为他是独占的。所以,建议您生成缓存工作空间(sxwu格式),可有效提高访问性能。

然后,在代码里,要保证您的“var sceneName = "scene"中“scene” 确实是你的场景名称;

给您参考的范例:

http://support.supermap.com.cn:8090/iserver/iClient/for3D/plugin/samplecode/samplecode/samples/SceneView3D/BasicAction.html

http://support.supermap.com.cn:8090/iserver/iClient/for3D/plugin/samplecode/default.htm(也可以参考“场景浏览”下的其他范例)

另外为提高可读性, function SceneLoad()的内容可以直接放在function initCallback()下面

7月 11, 2017 用户: 郭宇杰 才疏学浅 (11 分)
谢谢您给我解答,但是还是没有解决,可以加您qq吗?我的qq号:799535747
...