default.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. 
  2. <html>
  3. <head>
  4. <meta http-equiv="x-ua-compatible" content="IE=8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <title>3D展现</title>
  7. <script type="text/javascript" src='libs/SuperMap.Include.js'></script>
  8. <script type="text/javascript" src="libs/Scripts/SuperMap.Include.js" ></script>
  9. <script type="text/javascript">
  10. var scene = null;
  11. var cameraType = "JL";
  12. var sceneControl = null;
  13. var htmlUrl = null;
  14. var strServerUrl = null;
  15. var layer3D = null;
  16. var infoPage = "noInfo.htm";
  17. var bubble = null;
  18. function getJson(path) {
  19. var fso, ts, s;
  20. var ForReading = 1;
  21. fso = new ActiveXObject("Scripting.FileSystemObject"); //调用控件
  22. ts = fso.OpenTextFile(path, ForReading);
  23. s = ts.ReadLine();
  24. return s;
  25. }
  26. var returnValue = '';
  27. function getData(args) {
  28. // alert(args);
  29. returnValue = getJson("C:/SuperMap/GettingStarted/json.txt"); //必须用绝对路径,该txt中的内容不要有换行
  30. alert(returnValue);
  31. };
  32. function getRequest() {
  33. var url = location.search; //获取url中"?"符后的字串
  34. var theRequest = new Object();
  35. if (url.indexOf("?") != -1) {
  36. var str = url.substr(1);
  37. strs = str.split("&");
  38. for(var i = 0; i < strs.length; i ++) {
  39. theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
  40. }
  41. }
  42. return theRequest;
  43. }
  44. function onPageLoad(index){
  45. var Request = new Object();
  46. Request = getRequest();
  47. cameraType = Request['cameraType'];
  48. //alert(curOpenWin);
  49. if (index == null || index == "" || index == undefined) {
  50. return;
  51. }
  52. if(navigator.userAgent.indexOf("MSIE") == -1) {
  53. return;
  54. }
  55. htmlUrl = document.location.host;
  56. //判断网页的打开方式是本地打开还是通过网络打开
  57. //不同的打开方式url赋值不同
  58. if (htmlUrl == "") {
  59. htmlUrl = "http://localhost:8090";
  60. }else{
  61. htmlUrl = "http://" + htmlUrl;
  62. }
  63. htmlUrl = "http://139.196.222.240:8090";
  64. strServerUrl = htmlUrl + "/iserver/services/3D-lygzone/rest/realspace";
  65. // strServerUrl = htmlUrl +"/iserver/services/3D-lyghuagong/rest/realspace";
  66. backColor = new SuperMap.Web.Core.Color(255, 0, 0, 100);
  67. //初始化三维场景控件
  68. try{
  69. sceneControl = new SuperMap.Web.UI.Controls.SceneControl($get("sceneControlDiv"),initCallBack,failedCallBack);
  70. }
  71. catch(e){
  72. //若没有安装插件,则抛出该异常
  73. if (e.name == SuperMap.Web.Realspace.ExceptionName.PluginNotInstalled) {
  74. var url = htmlUrl + "/iserver/iClient/for3D/Setup.exe";
  75. document.write("<a href= ' "+url+" '>未检测到SuperMap iClient3D for Plugin 插件,请单击此处下载安装。</a");
  76. }
  77. //若使用非IE浏览器,则抛出该异常
  78. else if (e.name == SuperMap.Web.Realspace.ExceptionName.BrowserNotSupport) {
  79. document.write("<p>SuperMap iClient3D for Plugin 目前仅支持InternetExplorer浏览器,请更换浏览器后重新加载本页面.</p>");
  80. }
  81. //抛出其他异常
  82. else{
  83. alert(e.message);
  84. }
  85. }
  86. }
  87. //控件初始化完成后的回调函数,初始化完成之后才能进行数据加载
  88. function initCallBack(){
  89. scene = sceneControl.get_scene();
  90. screenLayer = scene.get_screenLayer3D();
  91. sceneControl.addEvent("objectSelected",objectSelected);
  92. sceneControl.addEvent("bubbleInitialize",bubbleInitialize);
  93. sceneControl.addEvent("bubbleResize",bubbleResize);
  94. sceneControl.addEvent("bubbleClose",bubbleClose);
  95. //获取Realspace控件的场景,控件和场景是一对一的捆绑关系
  96. //新建一个照相机对象,把照相机的位置设置为中国的中心点
  97. // var camera = new SuperMap.Web.Realspace.Camera(104.348, 28.708, 10288740.0); //China
  98. var camera1 = new SuperMap.Web.Realspace.Camera(119.476521,34.749126,200.0); //ZR
  99. var camera2 = new SuperMap.Web.Realspace.Camera(119.38055, 34.74817,100.0); //JL
  100. //alert("disType["+cameraType+"]")
  101. var camera = camera1;
  102. if (cameraType == "JL") {
  103. //alert("家乐");
  104. camera = camera2;
  105. }
  106. //camera.set_tilt(65);
  107. //scene.get_flyingOperator().flyTo(camera,5000,400);
  108. var isOpen = scene.open(strServerUrl, "zr@lygzone");
  109. if (isOpen) {
  110. layer3D = scene.get_layer3Ds().get_item(0);
  111. if (layer3D != null) {
  112. //var mapUrl = "http://139.224.68.23:8090/iserver/services/map-tianditu/rest/maps/影像底图_经纬度";
  113. var mapUrl = "http://139.196.222.240:8090/iserver/services/map-tianditu/rest/maps/影像底图_经纬度";
  114. scene.get_layer3Ds().add(mapUrl,"影像底图_经纬度","影像底图_经纬度",SuperMap.Web.Realspace.Layer3DType.Map);
  115. var lyrBounds = layer3D.get_bounds();
  116. camera.set_tilt(65);
  117. // scene.get_flyingOperator().flyTo(lyrBounds,5000,20);
  118. scene.get_flyingOperator().flyTo(camera,2000,20);
  119. }
  120. }else{
  121. alert("打开场景失败");
  122. }
  123. //添加屏幕图层文本
  124. try {
  125. var anchorPoint = new SuperMap.Web.Core.Point3D(0.50,0.965,0);
  126. var txtPart3D = new SuperMap.Web.Core.TextPart3D("中设设计", anchorPoint);
  127. var textArray = [txtPart3D];
  128. var text3D = new SuperMap.Web.Core.GeoText3D(textArray);
  129. var feature3D = new SuperMap.Web.Core.Feature3D();
  130. feature3D.set_geometry(text3D);
  131. var textStyle = new SuperMap.Web.Core.TextStyle3D();
  132. textStyle.set_foreColor(new SuperMap.Web.Core.Color(255,255,0,255));
  133. textStyle.set_backColor(new SuperMap.Web.Core.Color(0,0,0,255));
  134. textStyle.set_outline(true);
  135. textStyle.set_fontName("微软雅黑");
  136. textStyle.set_fontScale(0.8);
  137. feature3D.set_textStyle3D(textStyle);
  138. scene.get_screenLayer3D().add(feature3D,"Text");
  139. scene.get_screenLayer3D().set_isVisible(true);
  140. }
  141. catch(e){
  142. alert("屏幕图层添加文字失败");
  143. }
  144. }
  145. //控件初始化失败后的回调函数
  146. function failedCallBack(){
  147. alert("Realspace initiallized failed");
  148. }
  149. function objectSelected(selected3d) {
  150. var selection3DCount = selected3d.length;
  151. for(var i=0; i<selection3DCount; i++)
  152. {
  153. var selectCount = selected3d[i].get_count();
  154. // alert("selectCount:"+ selectCount);
  155. for(var j=0; j<selectCount; j++)
  156. {
  157. var selection3D = selected3d[i];
  158. // alert("item:"+selection3D.get_item(j));
  159. }
  160. }
  161. // var layer3D = scene.get_layer3Ds().get_item("guanzi@ZR_1");
  162. // var fieldInfo = "";
  163. // fieldCount = layer3D.get_fieldInfos().get_count();
  164. // for(var i=0;i<fieldCount;i++)
  165. // {
  166. // fieldInfo += layer3D.get_fieldInfos().get_item(i).get_name() + ":";
  167. // fieldInfo += layer3D.getFieldValue(i) + "; ";
  168. // }
  169. // alert(fieldInfo);
  170. var objId = selected3d[0].get_item(0);
  171. var objInLayer3D = selected3d[0].get_layer3D();
  172. // alert("objInLayer3D:"+objId+";"+ objInLayer3D);
  173. var fieldInfo = "";
  174. fieldCount = objInLayer3D.get_fieldInfos().get_count();
  175. for(var i=0;i<fieldCount;i++)
  176. {
  177. fieldInfo += objInLayer3D.get_fieldInfos().get_item(i).get_name() + ":";
  178. fieldInfo += objInLayer3D.getFieldValue(i) + "; ";
  179. }
  180. // alert(fieldInfo);
  181. var featrue3D = objInLayer3D.findFeature3DByID(objId);
  182. var ModelName = objInLayer3D.getFieldValue(9);
  183. // alert("featrue3D:"+objId+";"+featrue3D);
  184. var point3D = null;
  185. if (featrue3D) {
  186. point3D = featrue3D.get_geometry().get_position();
  187. }
  188. var featureName = featrue3D.get_name();
  189. var path = "<%=basePath%>/theme/GettingStarted/";
  190. switch (ModelName) {
  191. case "TK_101":
  192. infoPage = path + "zr_1.htm";
  193. break;
  194. case "TK_102":
  195. infoPage = path + "zr_2.htm";
  196. break;
  197. case "TK_108":
  198. infoPage = path + "zr_8.htm";
  199. break;
  200. case "TK_107":
  201. infoPage = path + "zr_7.htm";
  202. break;
  203. case "TK_105":
  204. infoPage = path + "zr_5.htm";
  205. break;
  206. case "TK_106":
  207. infoPage = path + "zr_6.htm";
  208. break;
  209. case "TK_104":
  210. infoPage = path + "zr_4.htm";
  211. break;
  212. case "TK_103":
  213. infoPage = path + "zr_3.htm";
  214. break;
  215. case "TK_109":
  216. infoPage = path + "zr_9.htm"; //ball 9
  217. break;
  218. case "TK_110":
  219. infoPage = path + "zr_10.htm"; //ball 10
  220. break;
  221. default:
  222. infoPage = path + "noInfo.htm";
  223. break;
  224. }
  225. createBubble(point3D);
  226. }
  227. function createBubble(pos){
  228. try{
  229. bubble = new SuperMap.Web.Realspace.Bubble();
  230. bubble.set_pointer(pos);
  231. //设置气泡标题内容
  232. // var title = document.getElementById("TitleName").value;
  233. var title = "储罐信息";
  234. if (title != null) {
  235. bubble.set_title(title);
  236. }
  237. var textStyle3D = new SuperMap.Web.Core.TextStyle3D();
  238. //设置气泡标题对齐方式
  239. // var textAligns = document.getElementById("TextAlign");
  240. var textAligns = 10;
  241. for(var i=0;i<textAligns.length;i++)
  242. {
  243. if (textAligns[i].selected) {
  244. textStyle3D.set_alignment(textAligns[i].value);
  245. }
  246. }
  247. //设置标题文本字体
  248. //var fontNames = document.getElementById("FontName");
  249. textStyle3D.set_fontName("微软雅黑");
  250. //设置标题字体颜色
  251. textStyle3D.set_foreColor(new SuperMap.Web.Core.Color(255,255,255,100));
  252. bubble.set_titleTextStyle3D(textStyle3D);
  253. //设置气泡边框宽度
  254. var frameWidth = 8; //document.getElementById("FrameWidth").value;
  255. if (frameWidth != null) {
  256. bubble.set_frameWidth(frameWidth);
  257. }
  258. //设置气泡圆角程度
  259. var roundQuality = 1; //document.getElementById("RoundQuality").value;
  260. if (roundQuality != null) {
  261. bubble.set_roundQuality(roundQuality);
  262. }
  263. //设置边框颜色
  264. bubble.set_backColor(new SuperMap.Web.Core.Color(0,0,255,200));
  265. bubble.set_frameColor(new SuperMap.Web.Core.Color(255,255,255,255));
  266. bubble.set_height(380);
  267. bubble.set_width(600);
  268. sceneControl.get_bubbles().removeAll();
  269. sceneControl.get_bubbles().add(bubble);
  270. }
  271. catch(e){
  272. alert("创建气泡失败");
  273. }
  274. }
  275. function bubbleInitialize(bubble){
  276. try
  277. {
  278. var frameInfo = document.getElementById("infoWindow");
  279. frameInfo.src = infoPage;
  280. frameInfo.frameborder = 0;
  281. frameInfo.style.marginwidth = 0;
  282. frameInfo.style.marginheight = 0;
  283. frameInfo.style.width = bubble.get_clientWidth()+"px";
  284. frameInfo.style.height = bubble.get_clientHeight()+"px";
  285. frameInfo.style.left = bubble.get_clientLeft() + sceneControl.get_controlOffsetX()+"px";
  286. frameInfo.style.top = (bubble.get_clientTop() + sceneControl.get_controlOffsetY() - 45) +"px";
  287. frameInfo.style.display = "block";
  288. }
  289. catch(e){
  290. alert("Failed to initialize bubble");
  291. }
  292. }
  293. function bubbleResize(bubble){
  294. try
  295. {
  296. var frameInfo = document.getElementById("infoWindow");
  297. frameInfo.src = infoPage;
  298. frameInfo.style.width = bubble.get_clientWidth()+"px";
  299. frameInfo.style.height = bubble.get_clientHeight()+"px";
  300. frameInfo.style.left = bubble.get_clientLeft() + sceneControl.get_controlOffsetX()+"px";
  301. frameInfo.style.top = (bubble.get_clientTop() + sceneControl.get_controlOffsetY() - 45) +"px";
  302. frameInfo.style.display = "block";
  303. }
  304. catch(e)
  305. {
  306. alert("Failed to resize bubble");
  307. }
  308. }
  309. //关闭气泡
  310. function bubbleClose(bubble){
  311. try
  312. {
  313. var frameInfo = document.getElementById("infoWindow");
  314. frameInfo.style.display = "none";
  315. var selection3Ds = scene.findSelection3Ds(true);
  316. if (selection3Ds.length > 0) {
  317. for(var i = 0; i <= selection3Ds.length - 1; i++){
  318. selection3Ds[i].removeAll();
  319. }
  320. }
  321. }
  322. catch(e){
  323. alert("Failed to close bubble");
  324. }
  325. }
  326. </script>
  327. </head>
  328. <body onLoad="onPageLoad('ZR');">
  329. <meta http-equiv="x-ua-compatible" content="IE=8">
  330. <!-- JL -->
  331. <ul style="position: absolute;top: 1px;left:5px;right:5px;float:left">
  332. <li>边框宽度:<input name="text" type="text" id="FrameWidth" value="15" size="10"/></li>
  333. <li>边框背景颜色:<select id="FrameColor" ><option value="Red" >红色<option value="Green">绿色<option value="Blue" selected>蓝色</option></select></li>
  334. <li>标题名称:<input type="text" id="TitleName" value="球罐信息" size="" ></li>
  335. <li>标题字体:<select id="FontName"><option value="1" selected="selected">微软雅黑<option value="2">宋体<option value="3">隶书</select></li>
  336. <li>字体颜色:<select id="FontColor"><option value="Red">红色<option value="Green" selected="selected">绿色<option value="Blue">蓝色</select></li>
  337. <li>对齐方式:<select id="TextAlign"> <option value="9">左对齐<option value="11">右对齐<option value="10" selected="selected">居中对齐 </select></li>
  338. <li>圆角程度:<input id="RoundQuality" type="text" size="10px" value="1" style=""/></li>
  339. </ul>
  340. -->
  341. <p class="header"><span>连云港化工园区 </span></p>
  342. <p>
  343. <div id="sceneControlDiv" style="position:absolute;top: 0px;bottom: 0px;height:99%;width:99%"></div>
  344. <iframe id="infoWindow" style="position: absolute;top: 0px; display:none" frameborder="0" scrolling="auto">
  345. </iframe>
  346. </body>