123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
-
- <html>
- <head>
- <meta http-equiv="x-ua-compatible" content="IE=8">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>3D展现</title>
- <script type="text/javascript" src='libs/SuperMap.Include.js'></script>
- <script type="text/javascript" src="libs/Scripts/SuperMap.Include.js" ></script>
-
- <script type="text/javascript">
- var scene = null;
- var cameraType = "JL";
- var sceneControl = null;
-
- var htmlUrl = null;
- var strServerUrl = null;
- var layer3D = null;
- var infoPage = "noInfo.htm";
- var bubble = null;
- function getJson(path) {
- var fso, ts, s;
- var ForReading = 1;
- fso = new ActiveXObject("Scripting.FileSystemObject"); //调用控件
- ts = fso.OpenTextFile(path, ForReading);
- s = ts.ReadLine();
-
- return s;
- }
- var returnValue = '';
- function getData(args) {
- // alert(args);
- returnValue = getJson("C:/SuperMap/GettingStarted/json.txt"); //必须用绝对路径,该txt中的内容不要有换行
- alert(returnValue);
-
- };
- function getRequest() {
- var url = location.search; //获取url中"?"符后的字串
- var theRequest = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- strs = str.split("&");
- for(var i = 0; i < strs.length; i ++) {
- theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
- }
- }
- return theRequest;
- }
-
- function onPageLoad(index){
- var Request = new Object();
- Request = getRequest();
- cameraType = Request['cameraType'];
- //alert(curOpenWin);
- if (index == null || index == "" || index == undefined) {
- return;
- }
-
- if(navigator.userAgent.indexOf("MSIE") == -1) {
- return;
- }
-
- htmlUrl = document.location.host;
- //判断网页的打开方式是本地打开还是通过网络打开
- //不同的打开方式url赋值不同
- if (htmlUrl == "") {
- htmlUrl = "http://localhost:8090";
- }else{
- htmlUrl = "http://" + htmlUrl;
- }
- htmlUrl = "http://139.196.222.240:8090";
-
- strServerUrl = htmlUrl + "/iserver/services/3D-lygzone/rest/realspace";
- // strServerUrl = htmlUrl +"/iserver/services/3D-lyghuagong/rest/realspace";
-
-
-
- backColor = new SuperMap.Web.Core.Color(255, 0, 0, 100);
-
- //初始化三维场景控件
- 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/Setup.exe";
- document.write("<a href= ' "+url+" '>未检测到SuperMap iClient3D for Plugin 插件,请单击此处下载安装。</a");
- }
- //若使用非IE浏览器,则抛出该异常
- else if (e.name == SuperMap.Web.Realspace.ExceptionName.BrowserNotSupport) {
- document.write("<p>SuperMap iClient3D for Plugin 目前仅支持InternetExplorer浏览器,请更换浏览器后重新加载本页面.</p>");
- }
- //抛出其他异常
- else{
- alert(e.message);
- }
- }
- }
-
- //控件初始化完成后的回调函数,初始化完成之后才能进行数据加载
- function initCallBack(){
- scene = sceneControl.get_scene();
- screenLayer = scene.get_screenLayer3D();
-
- sceneControl.addEvent("objectSelected",objectSelected);
- sceneControl.addEvent("bubbleInitialize",bubbleInitialize);
- sceneControl.addEvent("bubbleResize",bubbleResize);
- sceneControl.addEvent("bubbleClose",bubbleClose);
-
- //获取Realspace控件的场景,控件和场景是一对一的捆绑关系
-
- //新建一个照相机对象,把照相机的位置设置为中国的中心点
- // var camera = new SuperMap.Web.Realspace.Camera(104.348, 28.708, 10288740.0); //China
- var camera1 = new SuperMap.Web.Realspace.Camera(119.476521,34.749126,200.0); //ZR
- var camera2 = new SuperMap.Web.Realspace.Camera(119.38055, 34.74817,100.0); //JL
-
- //alert("disType["+cameraType+"]")
- var camera = camera1;
- if (cameraType == "JL") {
- //alert("家乐");
- camera = camera2;
- }
-
- //camera.set_tilt(65);
-
- //scene.get_flyingOperator().flyTo(camera,5000,400);
-
- var isOpen = scene.open(strServerUrl, "zr@lygzone");
-
-
- if (isOpen) {
- layer3D = scene.get_layer3Ds().get_item(0);
- if (layer3D != null) {
- //var mapUrl = "http://139.224.68.23:8090/iserver/services/map-tianditu/rest/maps/影像底图_经纬度";
- var mapUrl = "http://139.196.222.240:8090/iserver/services/map-tianditu/rest/maps/影像底图_经纬度";
- scene.get_layer3Ds().add(mapUrl,"影像底图_经纬度","影像底图_经纬度",SuperMap.Web.Realspace.Layer3DType.Map);
- var lyrBounds = layer3D.get_bounds();
-
- camera.set_tilt(65);
- // scene.get_flyingOperator().flyTo(lyrBounds,5000,20);
-
- scene.get_flyingOperator().flyTo(camera,2000,20);
-
- }
- }else{
- alert("打开场景失败");
- }
-
-
- //添加屏幕图层文本
- try {
- var anchorPoint = new SuperMap.Web.Core.Point3D(0.50,0.965,0);
- var txtPart3D = new SuperMap.Web.Core.TextPart3D("中设设计", anchorPoint);
- var textArray = [txtPart3D];
- var text3D = new SuperMap.Web.Core.GeoText3D(textArray);
-
- var feature3D = new SuperMap.Web.Core.Feature3D();
- feature3D.set_geometry(text3D);
-
- var textStyle = new SuperMap.Web.Core.TextStyle3D();
- textStyle.set_foreColor(new SuperMap.Web.Core.Color(255,255,0,255));
- textStyle.set_backColor(new SuperMap.Web.Core.Color(0,0,0,255));
- textStyle.set_outline(true);
- textStyle.set_fontName("微软雅黑");
- textStyle.set_fontScale(0.8);
- feature3D.set_textStyle3D(textStyle);
-
- scene.get_screenLayer3D().add(feature3D,"Text");
- scene.get_screenLayer3D().set_isVisible(true);
- }
- catch(e){
- alert("屏幕图层添加文字失败");
- }
-
- }
-
- //控件初始化失败后的回调函数
- function failedCallBack(){
- alert("Realspace initiallized failed");
- }
-
-
- function objectSelected(selected3d) {
-
-
- var selection3DCount = selected3d.length;
-
- for(var i=0; i<selection3DCount; i++)
- {
- var selectCount = selected3d[i].get_count();
-
- // alert("selectCount:"+ selectCount);
- for(var j=0; j<selectCount; j++)
- {
- var selection3D = selected3d[i];
- // alert("item:"+selection3D.get_item(j));
- }
- }
- // var layer3D = scene.get_layer3Ds().get_item("guanzi@ZR_1");
-
- // var fieldInfo = "";
- // fieldCount = layer3D.get_fieldInfos().get_count();
- // for(var i=0;i<fieldCount;i++)
- // {
- // fieldInfo += layer3D.get_fieldInfos().get_item(i).get_name() + ":";
- // fieldInfo += layer3D.getFieldValue(i) + "; ";
- // }
- // alert(fieldInfo);
-
- var objId = selected3d[0].get_item(0);
- var objInLayer3D = selected3d[0].get_layer3D();
-
- // alert("objInLayer3D:"+objId+";"+ objInLayer3D);
-
- var fieldInfo = "";
- fieldCount = objInLayer3D.get_fieldInfos().get_count();
- for(var i=0;i<fieldCount;i++)
- {
- fieldInfo += objInLayer3D.get_fieldInfos().get_item(i).get_name() + ":";
- fieldInfo += objInLayer3D.getFieldValue(i) + "; ";
- }
- // alert(fieldInfo);
-
- var featrue3D = objInLayer3D.findFeature3DByID(objId);
- var ModelName = objInLayer3D.getFieldValue(9);
-
- // alert("featrue3D:"+objId+";"+featrue3D);
- var point3D = null;
- if (featrue3D) {
- point3D = featrue3D.get_geometry().get_position();
- }
-
- var featureName = featrue3D.get_name();
- var path = "<%=basePath%>/theme/GettingStarted/";
-
- switch (ModelName) {
- case "TK_101":
- infoPage = path + "zr_1.htm";
-
- break;
- case "TK_102":
- infoPage = path + "zr_2.htm";
- break;
-
- case "TK_108":
- infoPage = path + "zr_8.htm";
-
- break;
-
- case "TK_107":
- infoPage = path + "zr_7.htm";
- break;
-
- case "TK_105":
- infoPage = path + "zr_5.htm";
- break;
-
- case "TK_106":
- infoPage = path + "zr_6.htm";
-
- break;
-
- case "TK_104":
- infoPage = path + "zr_4.htm";
- break;
-
- case "TK_103":
- infoPage = path + "zr_3.htm";
- break;
-
- case "TK_109":
- infoPage = path + "zr_9.htm"; //ball 9
- break;
-
- case "TK_110":
-
- infoPage = path + "zr_10.htm"; //ball 10
- break;
-
- default:
- infoPage = path + "noInfo.htm";
-
- break;
- }
- createBubble(point3D);
- }
-
- function createBubble(pos){
- try{
- bubble = new SuperMap.Web.Realspace.Bubble();
- bubble.set_pointer(pos);
-
- //设置气泡标题内容
- // var title = document.getElementById("TitleName").value;
- var title = "储罐信息";
- if (title != null) {
- bubble.set_title(title);
- }
-
- var textStyle3D = new SuperMap.Web.Core.TextStyle3D();
-
- //设置气泡标题对齐方式
- // var textAligns = document.getElementById("TextAlign");
- var textAligns = 10;
- for(var i=0;i<textAligns.length;i++)
- {
- if (textAligns[i].selected) {
- textStyle3D.set_alignment(textAligns[i].value);
- }
- }
- //设置标题文本字体
- //var fontNames = document.getElementById("FontName");
- textStyle3D.set_fontName("微软雅黑");
-
- //设置标题字体颜色
-
- textStyle3D.set_foreColor(new SuperMap.Web.Core.Color(255,255,255,100));
-
- bubble.set_titleTextStyle3D(textStyle3D);
-
- //设置气泡边框宽度
- var frameWidth = 8; //document.getElementById("FrameWidth").value;
- if (frameWidth != null) {
- bubble.set_frameWidth(frameWidth);
- }
-
- //设置气泡圆角程度
- var roundQuality = 1; //document.getElementById("RoundQuality").value;
- if (roundQuality != null) {
- bubble.set_roundQuality(roundQuality);
- }
-
- //设置边框颜色
-
- bubble.set_backColor(new SuperMap.Web.Core.Color(0,0,255,200));
-
- bubble.set_frameColor(new SuperMap.Web.Core.Color(255,255,255,255));
-
- bubble.set_height(380);
- bubble.set_width(600);
-
- sceneControl.get_bubbles().removeAll();
- sceneControl.get_bubbles().add(bubble);
- }
- catch(e){
- alert("创建气泡失败");
- }
- }
-
- function bubbleInitialize(bubble){
- try
- {
- var frameInfo = document.getElementById("infoWindow");
- frameInfo.src = infoPage;
- frameInfo.frameborder = 0;
- frameInfo.style.marginwidth = 0;
- frameInfo.style.marginheight = 0;
- frameInfo.style.width = bubble.get_clientWidth()+"px";
- frameInfo.style.height = bubble.get_clientHeight()+"px";
- frameInfo.style.left = bubble.get_clientLeft() + sceneControl.get_controlOffsetX()+"px";
- frameInfo.style.top = (bubble.get_clientTop() + sceneControl.get_controlOffsetY() - 45) +"px";
- frameInfo.style.display = "block";
- }
- catch(e){
- alert("Failed to initialize bubble");
- }
- }
-
- function bubbleResize(bubble){
- try
- {
- var frameInfo = document.getElementById("infoWindow");
-
- frameInfo.src = infoPage;
-
- frameInfo.style.width = bubble.get_clientWidth()+"px";
- frameInfo.style.height = bubble.get_clientHeight()+"px";
- frameInfo.style.left = bubble.get_clientLeft() + sceneControl.get_controlOffsetX()+"px";
- frameInfo.style.top = (bubble.get_clientTop() + sceneControl.get_controlOffsetY() - 45) +"px";
- frameInfo.style.display = "block";
- }
- catch(e)
- {
- alert("Failed to resize bubble");
- }
- }
-
- //关闭气泡
- function bubbleClose(bubble){
- try
- {
- var frameInfo = document.getElementById("infoWindow");
- frameInfo.style.display = "none";
-
- var selection3Ds = scene.findSelection3Ds(true);
- if (selection3Ds.length > 0) {
- for(var i = 0; i <= selection3Ds.length - 1; i++){
- selection3Ds[i].removeAll();
- }
- }
- }
- catch(e){
- alert("Failed to close bubble");
- }
- }
- </script>
- </head>
- <body onLoad="onPageLoad('ZR');">
- <meta http-equiv="x-ua-compatible" content="IE=8">
- <!-- JL -->
- <ul style="position: absolute;top: 1px;left:5px;right:5px;float:left">
- <li>边框宽度:<input name="text" type="text" id="FrameWidth" value="15" size="10"/></li>
- <li>边框背景颜色:<select id="FrameColor" ><option value="Red" >红色<option value="Green">绿色<option value="Blue" selected>蓝色</option></select></li>
- <li>标题名称:<input type="text" id="TitleName" value="球罐信息" size="" ></li>
- <li>标题字体:<select id="FontName"><option value="1" selected="selected">微软雅黑<option value="2">宋体<option value="3">隶书</select></li>
- <li>字体颜色:<select id="FontColor"><option value="Red">红色<option value="Green" selected="selected">绿色<option value="Blue">蓝色</select></li>
- <li>对齐方式:<select id="TextAlign"> <option value="9">左对齐<option value="11">右对齐<option value="10" selected="selected">居中对齐 </select></li>
- <li>圆角程度:<input id="RoundQuality" type="text" size="10px" value="1" style=""/></li>
- </ul>
- -->
- <p class="header"><span>连云港化工园区 </span></p>
- <p>
- <div id="sceneControlDiv" style="position:absolute;top: 0px;bottom: 0px;height:99%;width:99%"></div>
- <iframe id="infoWindow" style="position: absolute;top: 0px; display:none" frameborder="0" scrolling="auto">
- </iframe>
- </body>
|