GettingStarted.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var sceneControl = null;
  2. function onPageLoad() {
  3. try
  4. {
  5. //获取 html 页面中名为 sceneControlDiv 的 div 对象作为场景控件
  6. sceneControl = new SuperMap.Web.UI.Controls.SceneControl($get("sceneControlDiv"), initCallback,failedCallback);
  7. }
  8. catch(e)
  9. {
  10. //console.log(e);
  11. }
  12. }
  13. var htmlUrl = document.location.host;
  14. if(htmlUrl == ""){ //判断网页的打开方式是本地打开还是通过网络打开
  15. htmlUrl = "http://localhost:8090"; }
  16. else{
  17. htmlUrl = "http://" + htmlUrl; }
  18. var sceneUrl = htmlUrl + "/iserver/services/components-rest/rest/realspace";
  19. //console.log(sceneUrl);
  20. //控件初始化完成后的回调函数,初始化完成后才能进行数据加载
  21. function initCallback() {
  22. //获取 Realspace 控件的场景,控件和场景是一对一关系
  23. scene = sceneControl.get_scene();
  24. scene.open(sceneUrl, "scene"); // 打开名称为”scene”的场景
  25. }
  26. //控件初始化失败的回调函数
  27. function failedCallback() {
  28. alert("Realspace initialized failed!");
  29. }
  30. function viewEntire()
  31. {
  32. scene.viewEntire(); //全局显示整个三维场景
  33. }
  34. function setPan()
  35. {
  36. var panAction = new SuperMap.Web.UI.Action3Ds.Pan(sceneControl);
  37. sceneControl.set_sceneAction(panAction); //场景平移
  38. }
  39. function setSelect()
  40. {
  41. var selectAction = new SuperMap.Web.UI.Action3Ds.Select(sceneControl);
  42. sceneControl.set_sceneAction(selectAction); //场景选择
  43. }
  44. function refresh()
  45. {
  46. scene.refresh();//刷新场景
  47. }