加载三维场景,我定义了一个场景,但浏览器加载出来2个场景,并且模型也没有显示出来,请问如何解决?
代码和效果如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="x-ua-compatible" content="IE=8">
<!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>-->
<title></title>
<script src="for3D/lib/lib_Ajax/MicrosoftAjax.js"></script>
<script src="for3D/lib/lib_Ajax/SuperMap-7.0.1-11323.js"></script>
<script src="for3D/lib/lib_Realspace/SuperMap.Web.Realspace.js"></script>
<script>
var sceneControl = null;
var scene = null;
var sceneUrl = "http://localhost:8090/iserver/services/3D-3D/rest/realspace";
var htmlUrl = document.location.host;
//判断网页的打开方式是本地打开还是通过网络打开
//不同的打开方式url赋值不同
if (htmlUrl == "") {
htmlUrl = "http://localhost:8090";
}
else {
htmlUrl = "http://" + htmlUrl;
}
function pageLoad() {
try{
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() {
//获取地球控件场景,控件和场景是一对一的捆绑关系
scene = sceneControl.get_scene();
//指定场景名字
//var sceneName = "flat@xxq";
//flat@xxq 3dScene
//打开场景 building@xxq
scene.open(sceneUrl, "3dScene");
//获取场景中的第一个图层
var layer3D = scene.get_layer3Ds().get_item("roadline_adjust_1@xxq");
if (layer3D != null) {
//获取图层的地理范围,并飞行到该范围
var geobound = layer3D.get_bounds();
scene.get_flyingOperator().flyToBounds(geobound);
alert("11");
} else {
alert(22);
}
}
function failedCallback() {
}
</script>
</head>
<body onload="pageLoad()">
<div id="SceneControlDiv"></div>
</body>
</html>
<style>
#SceneControlDiv {
width: 1000px;
height: 250px;
position: absolute;
top: 0px;
left: 100px;
z-index: 10;
border: 3px solid red;
}
</style>