var sceneControl = null; function onPageLoad() { try { //获取 html 页面中名为 sceneControlDiv 的 div 对象作为场景控件 sceneControl = new SuperMap.Web.UI.Controls.SceneControl($get("sceneControlDiv"), initCallback,failedCallback); } catch(e) { //console.log(e); } } var htmlUrl = document.location.host; if(htmlUrl == ""){ //判断网页的打开方式是本地打开还是通过网络打开 htmlUrl = "http://localhost:8090"; } else{ htmlUrl = "http://" + htmlUrl; } var sceneUrl = htmlUrl + "/iserver/services/components-rest/rest/realspace"; //console.log(sceneUrl); //控件初始化完成后的回调函数,初始化完成后才能进行数据加载 function initCallback() { //获取 Realspace 控件的场景,控件和场景是一对一关系 scene = sceneControl.get_scene(); scene.open(sceneUrl, "scene"); // 打开名称为”scene”的场景 } //控件初始化失败的回调函数 function failedCallback() { alert("Realspace initialized failed!"); } 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();//刷新场景 }