var Gis = function () { /* * 参数配置 */ var serverIp = config.getServerIp(); var tomcatIP = config.getTomcatIP(); var locaServerIp = config.getLocaServerIp(); var dbIp = config.getDbIp(); var serverPort = config.getServerPort(); var tomcatPort = config.getTomcatPort(); var locaServerPort = config.getLocaServerPort(); var dbUserName = config.getDbUserName(); var dbPassword = config.getDbPassword(); var groundLayerName = config.getGroundLayerName(); var dbServer = config.getDbServer(); var deployName = config.getDeployName(); var defaultRelativeDir = config.getDefaultRelativeDir(); var localhost = config.getLocalhost(); var lagerDevice; //全局变量 var globalControl = null; var actionCache = new Array();//用于存储已经attachEvent //显示管线、对象信息用到的: var featureTooltip = null;//气泡 var temp = 0; var ds = null; //添加设备用到的: var x; var y; var feature; var layerDevice; var layerVideo; //雨水管线管井液位添加至此图层 var cacheLayer = "waterFlow"; //液位计测得的最新液位值显示的液位加至此图层 var layerLiquid = "liquid"; //透明度条Name var silderBarName = "silderBarGlobeOpaque"; //初始视角 var initCameraState; //液位传感器区域统计 var selectedFeatures = new Array(); //控制圖例圖片 var btnTuli; var fiberLabelFeat; var detectActiveX = function () { try { var comActiveX = new ActiveXObject("LOCASPACEPLUGIN.LocaSpacePluginCtrl.1"); } catch (e) { return false; } return true; }; var initGlobal = function () { var earthDiv = document.getElementById("earthDiv"); if (detectActiveX() == false) { // earthDiv.innerHTML = "<OBJECT ID=\"MyGlobal\" CLASSID=\"CLSID:0E7A33FF-6238-41A6-A38D-AC3F755F92B6\" WIDTH=\"100%\" HEIGHT=\"100%\"><param name=\"wmode\" value=\"transparent\"></OBJECT>"; earthDiv.innerHTML = "<a href=\"" + localhost + $('#context').val() + "/plugins/LocaSpacePlugin.msi\">您还没安装GeoSceneGlobal,点击这里安装!</a>" $("#arlam_record_layout").css("height", 100); $("#centerArea").css("height", 100); } else { try { earthDiv.innerHTML = "<OBJECT ID=\"MyGlobal\" CLASSID=\"CLSID:0E7A33FF-6238-41A6-A38D-AC3F755F92B6\" WIDTH=\"100%\" HEIGHT=\"100%\"><param name=\"wmode\" value=\"transparent\"></OBJECT>"; globalControl = document.getElementById("MyGlobal"); // globalControl.Globe.LatLonGridVisible = false; // 设置三维控件的经纬度为不显示 globalControl.Globe.UnderGroundFloor.Visible = false; globalControl.Globe.NetCacheUsing = true; var color = globalControl.CreateColorRGBA(); color.SetValue(255, 255, 255, 255); globalControl.Globe.UserBackgroundColorValid = true; globalControl.Globe.UserBackgroundColor = color; featureTooltip = globalControl.CreateBalloonEx(); featureTooltip.Create(globalControl.Handle);// 创建气泡 featureTooltip.SetSize(4, 400); //宽度 featureTooltip.SetSize(5, 300); //高度 //设置点击事件 by liyulong 2015.9.24 Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon);// Gis.attachEvent("FireCameraBeginMove", Gis.hideballoon);// FireCameraBeginMove Gis.attachEvent("FireFeatureMouseInto", Gis.mouseinto); Gis.attachEvent("FireFeatureMouseOut", Gis.mouseout); //globalControl.Globe.Rain.Visible=true; globalControl.Globe.OverviewControl.Visible = false; globalControl.Globe.LatLonGridVisible = false;//初始化地球时取消经纬线显示; //globalControl.Globe.UsingVBO = false; globalControl.Globe.NetCacheUsing = true; //控制是否启用模型网络缓存,默认为true globalControl.Globe.ReleaseMemOutOfView = true; // 控制模型移出视口是否释放显存和内存 //暂时飞到二院 initCameraState = gisTools.getEyLocation(); Gis.getGlobalControl().Globe.JumpToCameraState(initCameraState); //globalControl.Globe.Refresh(); } catch (e) { alert(e.description); } } }; var connectServer = function () { try { if (globalControl != null) { //连接locaserver globalControl.Globe.ConnectServer(locaServerIp, locaServerPort, "", ""); globalControl.Globe.GroundOpaque = 0.5; globalControl.Globe.DefaultRelativeDir = defaultRelativeDir; //连接ORACLE数据库(地球中显示管线数据) ds = globalControl.Globe.DataManager.OpenOracleDataSource(dbServer, "", "", dbUserName, dbPassword); } } catch (e) { alert(e.description); } }; /* * ******************************************************************************************* * 代码块:清除所有地球关联各种操作的事件 start * ******************************************************************************************* */ //以下是新的思路来解决问题 function pair(eventName, callback) { this.eventName = eventName; this.callback = callback; } var checkEvent = function (eventName) { if ("FireFeatureMouseClick" == eventName || "MouseDown" == eventName || "FireTrackPolygonEnd" == eventName || "MouseUp" == eventName) { return true; } return false; }; var addEvent = function (eventName, callback) { if (checkEvent(eventName)) { actionCache.push(new pair(eventName, callback)); } }; var delEvent = function (eventName, callback) { if (checkEvent(eventName)) { for (var i = actionCache.length - 1; i >= 0; i--) { if (actionCache[i].eventName == eventName && actionCache[i].callback == callback) { actionCache.splice(i, 1); return; } } } }; /* * ******************************************************************************************* * 代码块:清除所有地球关联各种操作的事件 end * ******************************************************************************************* */ return { /** *切換圖例圖片 */ setSymbolImage: function (imageUrl, height, width) { btnTuli.SetImage1(localhost + $('#context').val() + imageUrl); btnTuli.Height = height; btnTuli.Width = width; }, drawPolygonWithFontColor: function (points, text, newFillColor, featName) { var newFeature = globalControl.CreateFeature(); var geoPolygon = globalControl.CreateGeoPolygon3D(); var polygonPnts = globalControl.CreatePoint3ds(); for (var i = 0; i < points.length; i++) { polygonPnts.Add(points[i].x, points[i].y, 0);//添加点,一个面的组成至少有3个点 } geoPolygon.AddPart(polygonPnts); var stylePolygon = globalControl.CreateSimplePolygonStyle3D(); stylePolygon.OutlineVisible = true;//面的外边框 /* var newFillColor = globalControl.CreateColorRGBA(); if (color >= 10) {//根据漏损率填充不同颜色的区域 newFillColor.SetValue(255, 0, 0, 100);//填充颜色,对应红、绿、蓝、透明度 } else if (color < 10) { newFillColor.SetValue(0, 0, 255, 100); } else { newFillColor.SetValue(255, 100, 38, 100); }*/ stylePolygon.FillColor = newFillColor; geoPolygon.Style = stylePolygon; geoPolygon.AltitudeMode = 2; geoPolygon.moveZ(4); newFeature.Geometry = geoPolygon; var label = globalControl.CreateLabel(); label.Text = text; label.Style = globalControl.CreateLabelStyle(); label.Style.TextStyle = globalControl.CreateTextStyle(); label.Style.TextStyle.FontSize = 14; label.Style.TextStyle.ForeColor = newFillColor; newFeature.Label = label; newFeature.Name = featName; globalControl.Globe.MemoryLayer.AddFeature(newFeature); globalControl.Globe.JumpToFeature(newFeature, 2000); }, /** * 在MemoryLayer增加feature * * points : [{x:12.4545,y:34.34343},{x:23.434343,y:45454.34343},{x:32.4343,y:34.434232}],points用于存放区域中各个点的坐标。 * text : 用于存放区域上需要添加的文字描述 */ drawPolygon: function (points, text, color, name) { var newFeature = globalControl.CreateFeature(); var geoPolygon = globalControl.CreateGeoPolygon3D(); var polygonPnts = globalControl.CreatePoint3ds(); for (var i = 0; i < points.length; i++) { polygonPnts.Add(points[i].x, points[i].y, 0);//添加点,一个面的组成至少有3个点 } geoPolygon.AddPart(polygonPnts); var stylePolygon = globalControl.CreateSimplePolygonStyle3D(); stylePolygon.OutlineVisible = true;//面的外边框 var newFillColor = globalControl.CreateColorRGBA(); if (color >= 10) {//根据漏损率填充不同颜色的区域 newFillColor.SetValue(255, 0, 0, 100);//填充颜色,对应红、绿、蓝、透明度 } else if (color < 10) { newFillColor.SetValue(0, 0, 255, 100); } else { newFillColor.SetValue(255, 100, 38, 100); } stylePolygon.FillColor = newFillColor; geoPolygon.Style = stylePolygon; geoPolygon.AltitudeMode = 2; geoPolygon.moveZ(2); newFeature.Geometry = geoPolygon; var label = globalControl.CreateLabel(); label.Text = text; newFeature.Label = label; if ("" != name || null != name) { newFeature.Name = name; } globalControl.Globe.MemoryLayer.AddFeature(newFeature); globalControl.Globe.JumpToFeature(newFeature, 2000); }, /** * 调整透明度 * * @param layerOpaque */ setlayerOpaque: function (layerOpaque) { if (globalControl != null) { globalControl.Globe.GroundOpaque = layerOpaque; var layer = globalControl.Globe.Layers.getLayerByCaption(groundLayerName); if (layer != null) { layer.Opaque = layerOpaque * 100; } var layerBuilding = globalControl.Globe.Layers.getLayerByCaption("jianzhu"); if (layerBuilding != null) { layerBuilding.Opaque = layerOpaque * 100; } } }, getGlobalControl: function () { return globalControl; }, getInitCameraState: function () { return initCameraState; }, getCacheLayer: function () { return cacheLayer; }, getLayerLiquid: function () { return layerLiquid; }, getLayerDevice: function () { return layerDevice; }, /** * 初始化ActiveX插件,连接服务器 */ initEarth: function () { if ($('#earthDiv').size() != 0) { initGlobal(); connectServer(); } }, /** * 从数据库中加载所需图层信息 */ loadData: function () { try { if (null != ds) { var roleName = $('#roleName').val(); gisTools.showSitePipe(ds,roleName); } } catch (e) { alert(e); } }, /** * 绑定事件 * * @param eventName * @param callback */ attachEvent: function (eventName, callback) { if (globalControl == null) { alert("未初始化地球控件"); } addEvent(eventName, callback); globalControl.Globe.FeatureMouseOverEnable = true; globalControl.attachEvent(eventName, callback); }, /** * 解除时间绑定 * * @param eventName * @param callback */ detachEvent: function (eventName, callback) { if (globalControl == null) { alert("未初始化地球控件"); } delEvent(eventName, callback); globalControl.detachEvent(eventName, callback); switch (eventName) { case 'FireTrackPolygonEnd': globalControl.Globe.ClearLastTrackPolygon(); globalControl.Globe.Action = 0; break; } }, /** * 封装Globe.Action设置,对应值功能描述见《LocaSpace javascript API开发手册》2.4.1 * * @param mode */ setAction: function (mode) { try { if (globalControl != null) { globalControl.Globe.Action = mode; globalControl.refresh(); } } catch (e) { alert(e.description); } }, /** * 增加模型至图层(目前主要用于增加传感设备至“传感设备图层”) * * @param modelPath 模型在服务器端的路径 * @param descn feature的描述 * @param layerName 图层的名称 * @param pos 必须为var position=globalControl.CreatePoint3d(); * @param featureId 要素的名称 * @param fields * @param values */ addModelToLayer: function (modelPath, descn, layerName, pos, featureId, fields, values) { try { var layer = globalControl.Globe.Layers.GetLayerByCaption(layerName); if (layer.GetFeatureByName(featureId, true).Count != 0) { alert("该要素已经存在:" + featureId); return; } var feature = layer.Dataset.CreateFeature(); var model = globalControl.CreateGeoModel(); model.FilePath = modelPath; model.Position = pos; model.AltitudeMode = 0; //调整模型入库的大小,三个参数分别为长宽高放大的倍数 //model.Scale(5,5,5); feature.Geometry = model; feature.Name = featureId; for (var i = 0; i < fields.length; i++) { feature.SetFieldValue(fields[i], values[i]); } layer.AddFeature(feature); layer.save(); alert("添加模型成功!"); } catch (e) { alert("添加模型错误"); } }, /** * * @param featureId 要数ID,推荐使用数据库主键 * @param layerName 图层名称 */ removeFeatureById: function (featureId, layerName) { var layer = globalControl.Globe.Layers.GetLayerByCaption(layerName); if (layer == null) { alert("无该图层" + layerName); } if (featureId != null) { var features = layer.GetFeatureByName(featureId, false); for (var i = 0; i < features.Count; i++) { var feature = features.Item(i); feature.Delete(); } layer.Save(); globalControl.Refresh(); } }, /** * 透明度条监听事件 * * @param sender * @param e */ updateGlobeOpaque: function (sender, e) { if (sender.Name == silderBarName) { var opaque = sender.SliderValue; Gis.setlayerOpaque(opaque); } }, /** * 初始化Gis地球上的按钮组 */ initGisTools: function () { var globeOpaqueId = setInterval(function () {//设置图层透明度为50% var layer = globalControl.Globe.Layers.getLayerByCaption(groundLayerName); if (layer != null) { Gis.setlayerOpaque(0.6); clearInterval(globeOpaqueId); } }, 100); //透明度条调整 var HudSlider = globalControl.CreateHudSliderBar(); HudSlider.Name = silderBarName; var offset = globalControl.CreatePoint2d(); offset.X = 0; offset.Y = 0; HudSlider.OffSet = offset; HudSlider.MinOpaque = 100; HudSlider.MaxOpaque = 255; HudSlider.BarLength = 400; //滑动条长度 HudSlider.SliderValue = 0.5; //滑动条的值 HudSlider.Align = 2; globalControl.Globe.AddHudControl(HudSlider); globalControl.attachEvent("FireHudControlMouseMove", Gis.updateGlobeOpaque);//事件绑定 globalControl.attachEvent("FireHudControlMouseUp", Gis.updateGlobeOpaque);//事件绑定 //按钮通用变量 var offset; var btnOffset; var color = globalControl.CreateColorRGBA(); color.SetValue(0, 0, 0, 255); var textstyle = globalControl.CreateTextStyle(); textstyle.ForeColor = color; textstyle.FontSize = 9; //快速定位按钮 var btnLocation = globalControl.CreateHudButton; btnLocation.Name = "swdh"; btnLocation.SetImage1(localhost + $('#context').val() + "/images/earth/btn_navi1.png");//($('#context').val()+"/s/media/image/bg/1.jpg"); btnLocation.MinOpaque = 0.7; btnLocation.MaxOpaque = 0.7; btnLocation.Text = "快速定位"; btnLocation.TextStyle = textstyle; btnLocation.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = 0; btnOffset.Y = -10; btnLocation.textOffset = btnOffset; btnLocation.Height = 40; btnLocation.Width = 40; offset = globalControl.CreatePoint2d(); offset.X = 5; offset.Y = 0; btnLocation.Offset = offset; //选择对象按钮 var btnSelect = globalControl.CreateHudButton; btnSelect.Name = "xzdx"; btnSelect.SetImage1(localhost + $('#context').val() + "/images/earth/btn_select.png");//($('#context').val()+"/s/media/image/bg/1.jpg"); btnSelect.MinOpaque = 0.7; btnSelect.MaxOpaque = 0.7; btnSelect.Text = "选择对象"; btnSelect.TextStyle = textstyle; btnSelect.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = 0; btnOffset.Y = -10; btnSelect.textOffset = btnOffset; btnSelect.Height = 40; btnSelect.Width = 40; btnSelect.Align = 5; offset = globalControl.CreatePoint2d(); offset.X = 10; offset.Y = 0; btnSelect.Offset = offset; //清除分析按钮 var btnClear = globalControl.CreateHudButton; btnClear.Name = "clear"; btnClear.SetImage1(localhost + $('#context').val() + "/images/earth/btn_clear.png");//($('#context').val()+"/s/media/image/bg/1.jpg"); btnClear.MinOpaque = 0.7; btnClear.MaxOpaque = 0.7; btnClear.Text = "清除分析"; btnClear.TextStyle = textstyle; btnClear.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = 0; btnOffset.Y = -10; btnClear.textOffset = btnOffset; btnClear.Height = 40; btnClear.Width = 40; offset = globalControl.CreatePoint2d(); offset.X = 60; offset.Y = 0; btnClear.Offset = offset; //显示或隐藏流向按钮 //显示流向按钮 var btnRainDir = globalControl.CreateHudButton; btnRainDir.Name = "rainDir"; btnRainDir.SetImage1(localhost + $('#context').val() + "/images/earth/btn_rainLevel2.png"); btnRainDir.MinOpaque = 0.7; btnRainDir.MaxOpaque = 0.7; btnRainDir.Text = "显示流向"; btnRainDir.TextStyle = textstyle; btnRainDir.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = 0; btnOffset.Y = -10; btnRainDir.textOffset = btnOffset; btnRainDir.Height = 40; btnRainDir.Width = 40; offset = globalControl.CreatePoint2d(); //offset.X = 335; offset.X = 110; offset.Y = 0; btnRainDir.Offset = offset; // //刷新按钮 // var btnRefresh = globalControl.CreateHudButton; // btnRefresh.Name = "refresh"; // btnRefresh.SetImage1(localhost + $('#context').val() + "/images/earth/btn_clear.png");//($('#context').val()+"/s/media/image/bg/1.jpg"); // btnRefresh.MinOpaque = 0.7; // btnRefresh.MaxOpaque = 0.7; // btnRefresh.Text = seconds+":秒"; // btnRefresh.TextStyle = textstyle; // btnRefresh.textAlign = 7; // btnOffset = globalControl.CreatePoint2d(); // btnOffset.X = 0; // btnOffset.Y = -10; // btnRefresh.textOffset = btnOffset; // btnRefresh.Height = 40; // btnRefresh.Width = 40; // offset = globalControl.CreatePoint2d(); // offset.X = 200; // offset.Y = 0; // btnRefresh.Offset = offset; //浏览模式按钮 var btnScanMode = globalControl.CreateHudButton; btnScanMode.Name = "ScanMode"; btnScanMode.SetImage1(localhost + $('#context').val() + "/images/earth/btn_hand.png"); btnScanMode.MinOpaque = 0.7; btnScanMode.MaxOpaque = 0.7; btnScanMode.Text = "浏览模式"; btnScanMode.TextStyle = textstyle; btnScanMode.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = -1; btnOffset.Y = -10; btnScanMode.textOffset = btnOffset; btnScanMode.Height = 40; btnScanMode.Width = 40; btnScanMode.Align = 5; offset = globalControl.CreatePoint2d(); offset.X = 10; offset.Y = 55; btnScanMode.Offset = offset; //图例 btnTuli = globalControl.CreateHudButton; btnTuli.Name = "tuli"; btnTuli.SetImage1(localhost + $('#context').val() + "/images/earth/tuli.png"); btnTuli.MinOpaque = 0.7; btnTuli.MaxOpaque = 0.7; btnTuli.Text = ""; btnTuli.TextStyle = textstyle; btnTuli.textAlign = 7; btnOffset = globalControl.CreatePoint2d(); btnOffset.X = -1; btnOffset.Y = -10; btnTuli.textOffset = btnOffset; btnTuli.Height = 200; btnTuli.Width = 310; btnTuli.Align = 6; offset = globalControl.CreatePoint2d(); offset.X = 00; offset.Y = 20; btnTuli.Offset = offset; globalControl.Globe.AddHudControl(btnLocation); globalControl.Globe.AddHudControl(btnSelect); globalControl.Globe.AddHudControl(btnClear); globalControl.Globe.AddHudControl(btnScanMode); globalControl.Globe.AddHudControl(btnTuli); globalControl.Globe.AddHudControl(btnRainDir); // globalControl.Globe.AddHudControl(btnRefresh); Gis.attachEvent('FireHudControlMouseDown', function (sender, e) { Gis.initEvents(); switch (sender.Name) { //快速定位 case 'swdh': // globalControl.Globe.JumpToCameraState(initCameraState); // Gis.setAction(0); // gisTools.clearMouseUpEvent(); // gisTools.clearFeatureMouseClickEvent(); // Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); Gis.closeAllFrames(); Gis.setAction(0); gisTools.clearMouseUpEvent(); gisTools.clearFeatureMouseClickEvent(); Gis.attachEvent("MouseUp", Gis.addDevice); break; //选择对象 case 'xzdx': Gis.closeAllFrames(); Gis.setAction(5); //var layer0 = Gis.getGlobalControl().Globe.Layers.GetLayerByCaption("雨水管线"); //layer0.saveAs("D:/雨水管线.lgd"); break; //清除分析 case 'clear': Gis.closeAllFrames(); Gis.clearCalculate(); Gis.setSymbolImage("/images/earth/tuli.png", 140, 290); break; case 'ScanMode': Gis.setAction(0); gisTools.clearMouseUpEvent(); gisTools.clearFeatureMouseClickEvent(); Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); Gis.clearCutArea(); break; case 'rainDir': if (null != ds) { var visible = false; if ("显示流向" == btnRainDir.Text) { btnRainDir.Text = "关闭流向"; visible = true; } else if ("关闭流向" == btnRainDir.Text) { btnRainDir.Text = "显示流向"; visible = false; } for (var i = 0; i < ds.Count; i++) { var layerName = ds.Item(i).Caption(); if (layerName.indexOf("管线") == layerName.length - 2) { Gis.pipelineLiuXiang(layerName, visible); } } } break; } }); }, /** * 根据ID 获取该层所有feature * * @param id * @returns {*} * @constructor */ GetAllFeaturesByID: function (id) {// 通过图层id获取该图层的所有要素 if (globalControl.Globe.Layers.Count > 0) {// 判断场景中是否有加载数据 var pLayer = globalControl.Globe.Layers.GetLayerByID(id); // 根据图层id获取该图层 if (pLayer == null) return null; var allfeatures = pLayer.GetAllFeatures();// 获取该图层的所有要素。 if (allfeatures.Count > 0) { for (i = 0; i < allfeatures.Count; i++) { // 遍历图层中的所有要素 var featureFolder = allfeatures.Item(i); if (featureFolder.Features) { if (featureFolder.Features.Count != 0) { var features = featureFolder.Features; return features;// 返回所有要素 } } else { return allfeatures; } } } else { return allfeatures; } } return null; }, /** * 格式化日期字符串 * * @param date * @returns {string} */ myformatter: function (date) { var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d); }, myfullformatter: function (date) { var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mm = date.getMinutes(); var s = date.getSeconds(); return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d) + ' ' + h + ':' + (mm < 10 ? ('0' + mm) : mm) + ':' + (s < 10 ? ('0' + s) : s); }, /** * 显示全部管线 */ showAllPipeLayer: function () { for (var i = 0; i < globalControl.Globe.Layers.Count; i++) { var pLayer = globalControl.Globe.Layers.GetLayerByID(i); if (pLayer != null && pLayer.Caption().indexOf("管线") > -1) { pLayer.Visible = true; } } }, /** * 显示指定图层 * * @author liyulong * * @param layerNameList 数组,传递图层名字 */ showSomePipeLayer: function (layerNameList) { for (var i = 0; i < globalControl.Globe.Layers.Count; i++) { var pLayer = globalControl.Globe.Layers.GetLayerByID(i); if (pLayer != null && pLayer.Caption().indexOf("管线") > -1) { pLayer.Visible = false; } } for (var j = 0; j < layerNameList.length; j++) { var pLayer = globalControl.Globe.Layers.GetLayerByCaption(layerNameList[j]); if (pLayer != null) { pLayer.Visible = true; } } globalControl.refresh(); }, /** * 关闭所有iframe */ closeAllFrames: function () { var frames = document.getElementsByTagName("iframe"); for (var i = 0; i < frames.length; i++) { if (frames.item(i).id != "iframeDlg" &&//如果是地球下部的iframe就不进行任何操作 frames.item(i).id != "" && frames.item(i).id != "opaqueFrame" && frames.item(i).id != "iframeRight") { frames.item(i).style.display = "none"; } } }, /** * 横切后显示管井液位 * * @param polyline */ showCutLine: function (polyline) { var layer = globalControl.Globe.Layers.GetLayerByCaption("雨水管线"); polyline.MoveZ(10); var feature = globalControl.CreateFeature(); feature.Geometry = polyline.Clone(); feature.Geometry.AltitudeMode = 1; feature.Name = "区域截面"; globalControl.Globe.MemoryLayer.AddFeature(feature); if (layer != null) { Gis.BufferAnalysis(polyline, layer, 1.0); } //Gis.detachEvent("FireTrackPolylineEnd", Gis.showCutLine); Gis.setAction(0); gisTools.clearMouseUpEvent(); gisTools.clearFeatureMouseClickEvent(); gisTools.clearFireTrackPolygonEndEvent(); Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); }, clearCutArea: function () { var layer = globalControl.Globe.MemoryLayer; var features = layer.getAllFeatures(); for (j = 0; j < features.Count; j++) { var feature = features.Item(j); if (feature != null && feature.Name == '区域截面') { feature.Delete(); } } }, addDevice: function () { layerDevice = $.layer({ type: 2, title: '按道路定位', area: ["320px", "200px"], maxWidth: '400', iframe: {src: $('#context').val() + '/content/alarm/deviceAdd.jsp'} }); Gis.setAction(0); gisTools.clearMouseUpEvent(); gisTools.clearFeatureMouseClickEvent(); Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); }, showVideo: function (hlsUrl) { $('#videoUrl').val(hlsUrl); Gis.closeAllFrames(); // layerVideo = $.layer({ // type: 2, // title: '视频播放', // area: ["700px", "500px"], // maxWidth: '700', // // iframe: {src: $('#context').val() + '/content/video/demo.html'} // iframe: {src: $('#context').val() + '/content/video/demo.html'} // }); window.open( $('#context').val() +"/content/video/demo.html", "video", "height=450, width=620,toolbar=no,menubar=no,scrollbars=no, " + "resizable=no,location=no, status=no,titlebar=no,toolbar=no,z-look=yes"); }, /** * 清除测算结果 */ clearCalculate: function () { //清除label:除了marker关联的label,其他label都在memoryLayer中 globalControl.Globe.MemoryLayer.RemoveAllFeature(); globalControl.Globe.Layers.GetLayerByCaption(Gis.getCacheLayer()).RemoveAllFeature(); gisTools.showAllLayers(); gisTools.hideLabel();//隐藏label Gis.setAction(0); Gis.getGlobalControl().Globe.clearAnalysis(); globalControl.Refresh(); }, /** * 平台坐标转经纬度坐标 * @param x * @param y * @returns {*} */ point2dToPoint3D: function (x, y) { var point2d = globalControl.CreatePoint2d(); point2d.X = x; point2d.Y = y; var projectManager = globalControl.CreateProjectManager(); projectManager.SetCurProject(0); var point2d3D = projectManager.Inverse1(point2d); var point3D = globalControl.CreatePoint3D(); point3D.SetValue(point2d3D.X, point2d3D.Y, 0); return point3D; }, /** * 经纬度坐标转平面坐标 * @param point3D * @returns {*} */ point3DToPoint2d: function (point3D) { var point2d = globalControl.CreatePoint2d(); point2d.X = point3D.X; point2d.Y = point3D.Y; var projectManager = globalControl.CreateProjectManager(); projectManager.SetCurProject(0); var point2d3D = projectManager.Forward1(point2d); point2d.X = point2d3D.X; point2d.Y = point2d3D.Y; return point2d; }, /** * 显示指定的线状feature中液位的高度 * * @param feature 线状feature对象 * @param depth 液位高度 * @param trans 管线透明度 */ showFlow1: function (feature, depth, trans) { if (feature.Geometry == null || feature.Geometry.Type == 305) { alert("对象非线状Feature"); return; } var line = feature.Geometry; if (line.Style != null) { var color = line.Style.LineColor; color.A = trans; line.Style.LineColor = color; } var radius = line.Style.Radius; if (depth > radius * 2) { alert("水面高度超出管线直径"); return; } depth = depth * 0.9; var startPoint = line.item(0).item(0); var endPoint = line.item(0).item(1); var startPoint2d = Gis.point3DToPoint2d(startPoint); var startPoint2d2 = Gis.point3DToPoint2d(endPoint); var f = globalControl.CreateFeature(); var p = globalControl.CreateGeoPolygon3D(); var ps = globalControl.CreatePoint3ds(); var startPointJia = globalControl.CreatePoint3d(); var startPointJian = globalControl.CreatePoint3d(); var endPointJia = globalControl.CreatePoint3d(); var endPointJian = globalControl.CreatePoint3d(); var xieLv = (startPoint2d.Y - startPoint2d2.Y) / (startPoint2d.X - startPoint2d2.X); //管线按高度分十分,看水面在那个高度区间里面 var count = Math.floor(depth / (radius / 24)); var points = globalControl.CreatePoint3ds(); for (var j = 0; j <= count; j++) { var h1 = (radius / 24) * j; var z1 = startPoint.Z - radius + h1; var z2 = endPoint.Z - radius + h1; if (xieLv == 0) { var startPoint2dJia = Gis.point2dToPoint3D(startPoint2d.X + radius, startPoint2d.Y); var startPoint2dJian = Gis.point2dToPoint3D(startPoint2d.X - radius, startPoint2d.Y); var endPoint2dJia = Gis.point2dToPoint3D(endPoint2d.X + radius, endPoint2d.Y); var endPoint2dJian = Gis.point2dToPoint3D(endPoint2d.X - radius, endPoint2d.Y); startPointJia.SetValue(startPoint2dJia.X, startPoint2dJia.Y, z1); startPointJian.SetValue(startPoint2dJian.X, startPoint2dJian.Y, z1); endPointJian.SetValue(endPoint2dJia.X, endPoint2dJia.Y, z2); endPointJia.SetValue(endPoint2dJian.X, endPoint2dJian.Y, z2); } else { var angle = Math.atan(xieLv); var d = Math.sqrt((radius * radius) - ((h1 - radius) * (h1 - radius))); var sin = d * Math.sin(angle); var cos = d * Math.cos(angle); var startPoint2dJia = Gis.point2dToPoint3D(startPoint2d.X + sin, startPoint2d.Y - cos); var startPoint2dJian = Gis.point2dToPoint3D(startPoint2d.X - sin, startPoint2d.Y + cos); var startPoint2dJia2 = Gis.point2dToPoint3D(startPoint2d2.X + sin, startPoint2d2.Y - cos); var startPoint2dJian2 = Gis.point2dToPoint3D(startPoint2d2.X - sin, startPoint2d2.Y + cos) startPointJia.SetValue(startPoint2dJia.X, startPoint2dJia.Y, z1); startPointJian.SetValue(startPoint2dJian.X, startPoint2dJian.Y, z1); endPointJian.SetValue(startPoint2dJia2.X, startPoint2dJia2.Y, z2); endPointJia.SetValue(startPoint2dJian2.X, startPoint2dJian2.Y, z2); } points.Add2(startPointJia); points.Add2(startPointJian); points.Add2(endPointJia); points.Add2(endPointJian); } var z1 = startPoint.Z - radius + depth; var z2 = endPoint.Z - radius + depth; if (xieLv == 0) { var startPoint2dJia = Gis.point2dToPoint3D(startPoint2d.X + radius, startPoint2d.Y); var startPoint2dJian = Gis.point2dToPoint3D(startPoint2d.X - radius, startPoint2d.Y); var endPoint2dJia = Gis.point2dToPoint3D(endPoint2d.X + radius, endPoint2d.Y); var endPoint2dJian = Gis.point2dToPoint3D(endPoint2d.X - radius, endPoint2d.Y); startPointJia.SetValue(startPoint2dJia.X, startPoint2dJia.Y, z1); startPointJian.SetValue(startPoint2dJian.X, startPoint2dJian.Y, z1); endPointJian.SetValue(endPoint2dJia.X, endPoint2dJia.Y, z2); endPointJia.SetValue(endPoint2dJian.X, endPoint2dJian.Y, z2); } else { var angle = Math.atan(xieLv); var d = Math.sqrt((radius * radius) - ((depth - radius) * (depth - radius))); var sin = d * Math.sin(angle); var cos = d * Math.cos(angle); var startPoint2dJia = Gis.point2dToPoint3D(startPoint2d.X + sin, startPoint2d.Y - cos); var startPoint2dJian = Gis.point2dToPoint3D(startPoint2d.X - sin, startPoint2d.Y + cos); var startPoint2dJia2 = Gis.point2dToPoint3D(startPoint2d2.X + sin, startPoint2d2.Y - cos); var startPoint2dJian2 = Gis.point2dToPoint3D(startPoint2d2.X - sin, startPoint2d2.Y + cos); startPointJia.SetValue(startPoint2dJia.X, startPoint2dJia.Y, z1); startPointJian.SetValue(startPoint2dJian.X, startPoint2dJian.Y, z1); endPointJian.SetValue(startPoint2dJia2.X, startPoint2dJia2.Y, z2); endPointJia.SetValue(startPoint2dJian2.X, startPoint2dJian2.Y, z2); } ps.Add2(startPointJia); for (var j = count; j >= 0; j--) { ps.Add2(points.item(4 * j)); } for (var j = 0; j <= count; j++) { ps.Add2(points.item(4 * j + 1)); } ps.Add2(startPointJian); ps.Add2(startPointJia); ps.Add2(startPointJian); ps.Add2(endPointJia); for (var j = count; j >= 0; j--) { ps.Add2(points.item(4 * j + 2)); } for (var j = 0; j <= count; j++) { ps.Add2(points.item(4 * j + 3)); } ps.Add2(endPointJian); ps.Add2(endPointJia); ps.Add2(endPointJian); p.AddPart(ps); var water = p.ConvertToGeoWater(); water.Play(); water.WaveSpeedX = 20; water.WaveSpeedY = 20; water.AltitudeMode = 2; f.Geometry = water; //TODO LIST:加载到内存图层? var layer0 = Gis.getGlobalControl().Globe.Layers.GetLayerByCaption(Gis.getCacheLayer()); layer0.AddFeature(f); //绘制水面立面 var featureLiMian = globalControl.CreateFeature(); var p3d = globalControl.CreatePoint3Ds(); var point3dstart = globalControl.CreatePoint3D(); point3dstart.setValue(startPoint.X, startPoint.Y, startPoint.Z - radius + depth); var point3dend = globalControl.CreatePoint3D(); point3dend.setValue(endPoint.X, endPoint.Y, endPoint.Z - radius + depth); p3d.Add2(point3dstart); p3d.Add2(point3dend); var lineLiMian = globalControl.CreateGeoPolyline3D(); lineLiMian.addPart(p3d); featureLiMian.Geometry = lineLiMian; radius = radius * 0.9; lineLiMian.AltitudeMode = 2; var extendStyle = globalControl.CreateExtendSectionLineStyle3D(); var sectionPoints = globalControl.CreatePoint3ds(); var radiusLiMian = Math.sqrt(Math.abs((radius * radius) - ((depth - radius) * (depth - radius)))); if (depth > radius) { var _length = (radius - radiusLiMian) / 8; for (var j = 0; j <= 8; j++) { var x = 0 - _length * j - radiusLiMian; var y = Math.sqrt((radius * radius) - (x * x)) + radius - depth; var z = 0; var point3dItem = globalControl.CreatePoint3D(); point3dItem.SetValue(x, y, z); sectionPoints.Add2(point3dItem); } var lengthItem = (radius / 8); for (var j = 0; j <= 16; j++) { var x = lengthItem * j - radius; var y = -Math.sqrt((radius * radius) - (x * x)) - depth + radius; var z = 0; var point3dItem = globalControl.CreatePoint3D(); point3dItem.SetValue(x, y, z); sectionPoints.Add2(point3dItem); } for (var j = 8; j >= 0; j--) { var x = _length * j + radiusLiMian; var y = Math.sqrt((radius * radius) - (x * x)) + radius - depth; var z = 0; var point3dItem = globalControl.CreatePoint3D(); point3dItem.SetValue(x, y, z); sectionPoints.Add2(point3dItem); } } else { var lengthItem = (radiusLiMian * 2 / (count)); for (var j = 0; j <= count; j++) { var x = lengthItem * j - radiusLiMian; var y = -Math.sqrt((radius * radius) - (x * x)); var z = 0; var point3dItem = globalControl.CreatePoint3D(); point3dItem.SetValue(x, y, z); sectionPoints.Add2(point3dItem); } } var color = globalControl.CreateColorRGBA(); color.SetValue(112, 144, 201, 255); extendStyle.LineColor = color; extendStyle.SetSectionPoints(sectionPoints); extendStyle.Closed = false; extendStyle.SetAnchorByAlign(1);// topCenter lineLiMian.Style = extendStyle; featureLiMian.Geometry = lineLiMian; layer0.ObjectMaxVisibleDistance = 1000; layer0.AddFeature(featureLiMian); //featureLiMian.HighLight = true; }, /** * 功能:显示指定的方井feature的液位高度 * * @param length * @param width * @param percent * @param feature * @param layer */ showDepthInFangJin: function (length, width, percent, feature) { if (null == feature) { return; } if (feature.Geometry.Type != 305) {//判断是否模型 alert("请选择模型对象!"); return; } var model = feature.Geometry; var rotateAngel = model.RotateZ - 90; var topCenterPoint = model.GeoTopCenterPoint; var bottomCenterPoint = model.GeoBottomCenterPoint; var bottomCenterPoint2d = Gis.point3DToPoint2d(bottomCenterPoint); var height = (topCenterPoint.Z - bottomCenterPoint.Z) * percent; var pointTopLeft2d = Gis.point2dToPoint3D( bottomCenterPoint2d.X - noneGisTools.getHalfWidth(width, length, rotateAngel, 1), bottomCenterPoint2d.Y - noneGisTools.getHalfLength(width, length, rotateAngel, 1)); var pointTopRight2d = Gis.point2dToPoint3D( bottomCenterPoint2d.X + noneGisTools.getHalfWidth(width, length, rotateAngel, 3), bottomCenterPoint2d.Y - noneGisTools.getHalfLength(width, length, rotateAngel, 3)); var pointBottomLeft2d = Gis.point2dToPoint3D( bottomCenterPoint2d.X - noneGisTools.getHalfWidth(width, length, rotateAngel, 3), bottomCenterPoint2d.Y + noneGisTools.getHalfLength(width, length, rotateAngel, 3)); var pointBottomRight2d = Gis.point2dToPoint3D( bottomCenterPoint2d.X + noneGisTools.getHalfWidth(width, length, rotateAngel, 1), bottomCenterPoint2d.Y + noneGisTools.getHalfLength(width, length, rotateAngel, 1)); var pointTopLeft = globalControl.CreatePoint3d(); var pointTopRight = globalControl.CreatePoint3d(); var pointBottomLeft = globalControl.CreatePoint3d(); var pointBottomRight = globalControl.CreatePoint3d(); pointTopLeft.SetValue(pointTopLeft2d.X, pointTopLeft2d.Y, bottomCenterPoint.Z + height); pointTopRight.SetValue(pointTopRight2d.X, pointTopRight2d.Y, bottomCenterPoint.Z + height); pointBottomLeft.SetValue(pointBottomLeft2d.X, pointBottomLeft2d.Y, bottomCenterPoint.Z + height); pointBottomRight.SetValue(pointBottomRight2d.X, pointBottomRight2d.Y, bottomCenterPoint.Z + height); var f = globalControl.CreateFeature(); var p = globalControl.CreateGeoPolygon3D(); var ps = globalControl.CreatePoint3ds(); ps.Add2(pointTopLeft); ps.Add2(pointTopRight); ps.Add2(pointBottomRight); ps.Add2(pointBottomLeft); p.AddPart(ps); var extrudeStyle = globalControl.CreateExtrudeStyle(); extrudeStyle.ExtrudeType = 1; extrudeStyle.ExtrudeValue = -height; var polygonStyle = globalControl.CreateSimplePolygonStyle3D(); var color = globalControl.CreateColorRGBA(); color.SetValue(52, 85, 129, 255); polygonStyle.FillColor = color; extrudeStyle.BodyStyle = polygonStyle; extrudeStyle.HeadPartVisible = false; extrudeStyle.BodyPartVisible = true; var water = p.ConvertToGeoWater(); water.ExtrudeStyle = extrudeStyle; water.Play(); water.WaveSpeedX = 10; water.WaveSpeedY = 10; water.AltitudeMode = 2; f.Geometry = water; f.Name = "yewei," + feature.getFieldValue("编号"); var layer = Gis.getGlobalControl().Globe.Layers.GetLayerByCaption(Gis.getCacheLayer()); layer.visible = true; layer.AddFeature(f); }, /** * depth:深度,radius,井半径 * 功能:显示圆井feature的液位高度. */ showCircleWellLiquidLevel: function (feature, percent, radius) { if (feature == null || feature.Geometry.Type != 305) { return null; } var model = feature.Geometry; var point3d = model.GeoCenterPoint; var bottom = feature.Geometry.GeoBottomCenterPoint.Z; var top = feature.geometry.GeoTopCenterPoint.Z; var depth = (top - bottom) * percent; point3d.Z = bottom + depth; var line = globalControl.CreateGeoPolyline3D(); var ps = globalControl.CreatePoint3ds(); ps.Add2(point3d); ps.Add(point3d.X + 0.000000001, point3d.Y, point3d.Z); line.AddPart(ps); var polygonBuffer = line.CreateBuffer(0.8, true, radius, true, false); var polygon = globalControl.CreateGeoPolygon3D(); polygon.AltitudeMode = 1; var psOfPolygon = polygonBuffer.item(0); for (var i = 0; i < psOfPolygon.Count; i++) { var pointOfPolygon = psOfPolygon.item(i); if (pointOfPolygon != null && pointOfPolygon.Z == 0) { pointOfPolygon.Z = point3d.Z; } // psOfPolygon.item(i) = pointOfPolygon; } polygon.addPart(psOfPolygon); polygon.ExtrudeStyle = globalControl.CreateExtrudeStyle() polygon.ExtrudeStyle.ExtrudeType = 1; //拉伸模式 polygon.ExtrudeStyle.ExtrudeValue = depth;//拉伸长度 var extrudeStyle = globalControl.CreateExtrudeStyle(); extrudeStyle.ExtrudeType = 1; extrudeStyle.ExtrudeValue = -depth; var polygonStyle = globalControl.CreateSimplePolygonStyle3D(); var color = globalControl.CreateColorRGBA(); color.SetValue(52, 85, 129, 255); polygonStyle.FillColor = color; extrudeStyle.BodyStyle = polygonStyle; extrudeStyle.HeadPartVisible = false; extrudeStyle.BodyPartVisible = true; var water = polygon.ConvertToGeoWater(); water.ExtrudeStyle = extrudeStyle; water.Play(); var ff = globalControl.CreateFeature(); ff.Geometry = water; ff.Name = "yewei," + feature.getFieldValue("编号"); var watersLayer = Gis.getGlobalControl().Globe.Layers.GetLayerByCaption(Gis.getCacheLayer()); watersLayer.visible = true; watersLayer.AddFeature(ff); }, showAlarmTimeData: function (msgData) { $.extend($.gritter.options, { position: 'bottom-left' }); var unique_id = $.gritter.add({ position: 'bottom-left', title: '新报警消息!', text: msgData[temp], image: $('#context').val() + "/images/avatar1.jpg", //image: "", sticky: true, time: '', class_name: 'my-sticky-class' }); setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 10000); $(".gritter-item").click(function () { var sound = document.getElementById("sound"); sound.pause();// 暂停 var devCode = ""; devCode = $(".gritter-item p")[0].innerText.split('\r\n')[1]; var feature = DeviceService.getFeatureInLayer( DeviceService.getMarkerPrefix() + devCode, Gis.getLayerLiquid()); globalControl.Globe.JumpToFeature(feature, 20); feature.Label.Visible = true; }); // $(".gritter-item").css("position","absolute"); // $(".gritter-item").css("z-index","9999"); }, AlarmDeviceData: function () { var soundUrl = config.getLocalhost() + config.getDeployName() + "/template/alarm.mp3" // document.getElementById("sound").src = soundUrl; var date = new Date(); var currentDate = parent.Gis.myformatter(date) + " " + date.toLocaleTimeString(); jQuery.ajax({ type: "POST", dataType: 'json', url: $('#context').val() + "/alarm/alarm-record!queryLatestAlarmDate.do?loginDate=" + currentDate, success: function (msg) { var result = eval(msg); if (result.success) { var data = result.data; var msgData = []; var Msg = data.deviceTypeName + "</br>" + data.deviceCode; msgData.push(Msg); if (msgData.length != 0) { document.getElementById("sound").src = soundUrl; Gis.showAlarmTimeData(msgData); } // if(result.newDevInfo != null) { // var dev = result.newDevInfo; // gisTools.updateAlarmMarker(dev); // IndexJS.showRightList(); // } } } }); }, AlarmTimeData: function () { $.ajax({ type: "get", url: $("#rsUrl").val() + '/device/updateAlarmDeviceListForHomePage.do', crossDomain: true, data: {}, dataType: 'jsonp', jsonp: "jsoncallback", jsonpCallback: "success_jsoncallback", success: function (msg) { var result = eval(msg); if (result.success && result.newDevInfo != null) { var devs = result.newDevInfo; for (var i = 0; i < devs.length; i++) { gisTools.updateAlarmMarker(devs[i]); } IndexJS.showRightList(); } } }); }, showballoon: function (feature, evt) { if (null == feature) { return; } // 1.设备Marker if (feature.Name.indexOf(DeviceService.getMarkerPrefix()) == 0) { noneGisTools.drawDevDataCurve(feature); DeviceService.showEffect(feature, evt, featureTooltip); } if (feature.Name.indexOf(DeviceService.getMarkerPrefixConcen()) == 0) {//为集中器时 var labelVisible = !feature.Label.Visible; feature.Label.Visible = labelVisible; globalControl.Refresh(); } if (feature.Name.indexOf(DeviceService.getMarkerPrefixDig()) == 0) {//为开挖监测结果时 var labelVisible = !feature.Label.Visible; feature.Label.Visible = labelVisible; globalControl.Refresh(); } // 2.显示管线及管线附属物详细信息 var layerName = feature.Layer.Caption; if (layerName != "传感设备图层" && layerName != Gis.getCacheLayer() && layerName != Gis.getLayerLiquid()) { noneGisTools.showDetails(feature, evt, featureTooltip); } else if (layerName == "传感设备图层") { noneGisTools.showDevDetails(feature, evt, featureTooltip); } globalControl.Refresh(); }, hideballoon: function (feature, evt) {// 方法中的两个参数会在myGlobalCtrl的FireFeatureMouseClick事件触发时获取。 if (featureTooltip.Visible) { featureTooltip.HideBalloon(); } }, mouseinto: function (feature, evt) { if (feature.layer && "传感设备图层" == feature.layer.Caption && feature.getFieldValue("DEVICETYPE").indexOf("光纤") > -1) { var scenePoint = gisTools.screenToScene(evt.X, evt.Y); var dis = gisTools.getDisInFiber(feature, scenePoint[0], scenePoint[1]); var geometry = Gis.getGlobalControl().CreateGeoDynamicMarker(); var position = globalControl.CreatePoint3d(); position.X = scenePoint[0]; position.Y = scenePoint[1]; position.Z = 0; geometry.Position = position; var feat = globalControl.CreateFeature(); feat.Geometry = geometry; Gis.getGlobalControl().Globe.MemoryLayer.AddFeature(feat); var desc = "距离起始点" + dis + "米"; var fontColor = globalControl.CreateColorRGBA(); fontColor.SetValue(0, 0, 0, 255);//红色 fiberLabelFeat = gisTools.addLabel(feat, desc, fontColor, 14); fiberLabelFeat.Label.Visible = true; } }, mouseout: function (feature, evt) { if (feature.layer && "传感设备图层" == feature.layer.Caption && feature.getFieldValue("DEVICETYPE").indexOf("光纤") > -1) { fiberLabelFeat.delete(); } }, /** * 异步请求雨水管线level,并进行展示 */ showOneRainLevel: function () { var feature = globalControl.Globe.SelectedObject; if (feature == null) { return; } if ("雨水管线" != feature.layer.Caption() && "雨水管线附属物" != feature.layer.Caption()) { alert("请选择雨水管线或管井"); return; } var featureName = feature.getFieldValue(0); $.ajax({ type: "POST", url: $("#context").val() + "/alarm/rain-liquid-analy!getOneRainLevel.do", data: { dbCord: featureName }, success: function (data) { data = eval("(" + data + ")"); var list = data.split(","); if (null == list[0] || "" == list[0]) { list[0] = 0; } if (null == list[1] || "" == list[1]) { list[1] = 0; } if (featureName.indexOf("_4000_") > -1) { var desc = "实时液位:" + (list[0] / 1000.0).toFixed(2) + "(米)\n" + "高度百分比:" + (list[1] * 100).toFixed(1) + "%"; gisTools.addLabel(feature, desc); Gis.showFlow1(feature, list[0] / 1000.0, 50); } else { var desc = "实时液位:" + (list[0] / 1000.0).toFixed(2) + "(米)\n" + "高度百分比:" + (list[1] * 100).toFixed(1) + "%"; gisTools.addLabel(feature, desc); var length = 0; var width = 0; if (featureName.indexOf("_4001_") > -1) { var length = 0.75; var width = 0.75; } else if (featureName.indexOf("_4002_") > -1) { var length = 0.275; var width = 0.45; } Gis.showDepthInFangJin(length, width, list[0] / 1000.0, feature); } globalControl.Refresh(); } }); gisTools.clearMouseUpEvent(); gisTools.clearFeatureMouseClickEvent(); Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); Gis.setAction(0); }, /** * TODO LIST:弹出对应的jsp文件,显示当前绘制区域内的全量程液位监测仪对应的管径的液位 * * @param e * @constructor */ BufferAnalysis: function (e) { selectedFeatures = []; var layer = globalControl.Globe.Layers.GetLayerByCaption("传感设备图层"); var features = layer.FindFeaturesInPolygon(e, false); for (var i = 0; i < features.Count; i++) { var feature = features.item(i); var modelPath = feature.GetFieldValue(feature.GetFieldCount() - 1); if (modelPath.indexOf("液位") != -1) { selectedFeatures.push(feature); } } $("#arlam_record_layout").layout("expand", "south"); var iframe = document.getElementById("iframeDlg"); iframe.src = "content/alarm/selected-liquidDevice.jsp"; }, JumpToCameraState: function (Longitude, Latitude, Heading, Tilt, Distance, Altitude, AltitudeMode) { var cameraState = globalControl.CreateCameraState(); cameraState.Longitude = Longitude; cameraState.Latitude = Latitude; cameraState.Heading = Heading; cameraState.Tilt = Tilt; cameraState.Distance = Distance; cameraState.Altitude = Altitude; cameraState.AltitudeMode = AltitudeMode; globalControl.Globe.JumpToCameraState(cameraState); }, /** * 制定图层中动态创建带Label,maker的点要素对象 * * @param layer * @param lat * @param long * @param icon * @param desc * @param id * @param status(true:设备正常,false:设备异常) */ addMarkerFeatureInLayer: function (layer, lat, long, icon, id, description) { var feature = globalControl.CreateFeature(); var maker = globalControl.CreateGeoMarker(); var mstyle = globalControl.CreateMarkerStyle3D(); mstyle.IconPath = icon; mstyle.IconScale = 1.3; maker.Style = mstyle; maker.X = long;//经度 maker.Y = lat;//纬度 maker.Z = 0; feature.Geometry = maker; feature.Name = id; feature.Description = description; layer.AddFeature(feature); return feature; }, /***** * @param devCode * @param wellCode * @param attachLayer * @param liquidValue */ showOneLiquidLevel: function (devCode, wellCode, attachLayer, liquidValue) { $.ajax({ type: "POST", url: $("#context").val() + "/alarm/device!getWellDepth.do", data: { dbCord: wellCode, attachLayer: attachLayer }, success: function (data) { var wellDepth = eval("(" + data + ")"); var markFeat = DeviceService.getFeatureInLayer(devCode, DeviceService.getMainLayer()); gisTools.addWaterLevelByMarker(markFeat, liquidValue / wellDepth); } }); }, initEvents: function () { Gis.setAction(0); for (var i = actionCache.length - 1; i >= 0; i--) { var temp = actionCache[i]; globalControl.detachEvent(temp.eventName, temp.callback); } actionCache = new Array(); Gis.attachEvent("FireFeatureMouseClick", Gis.showballoon); }, /**** * 编辑设备时更新传感设备图层信息 * @param srcPath * @param destPath * @param srcDevId * @param destDevId * @param srcDevType * @param destDevType */ updateFeature: function (srcPath, destPath, srcDevId, destDevId, srcDevType, destDevType) { if (srcPath == destPath && srcDevId == destDevId && srcDevType == destDevType) { return; } var layer = globalControl.Globe.Layers.GetLayerByCaption("传感设备图层"); if (layer) { var features = layer.GetAllFeatures(); for (var i = 0; i < features.Count; i++) { var feature = features.Item(i); if (srcDevId == feature.GetFieldValue(1)) { var model = feature.Geometry; if (model.FilePath == (globalControl.Globe.DefaultRelativeDir + srcPath)) { model.FilePath = destPath; model.AltitudeMode = 0; } feature.Geometry = model; if (srcDevType != destDevType) { feature.SetFieldValue(0, destDevType); } if (srcDevId != destDevId) { feature.Name = destDevId; feature.SetFieldValue(1, destDevId); } layer.Save(); } } globalControl.refresh(); } }, //流向分析 pipelineLiuXiang: function (layerName, visible) { var layer = globalControl.Globe.Layers.GetLayerByCaption(layerName); if (null != layer) { var feats = layer.GetAllFeatures(); for (var j = 0; j < feats.Count; j++) { var feat = feats.Item(j); if (feat.Geometry.Type == 302) { var lineStyle = feat.Geometry.Style; if (lineStyle == null) { lineStyle = globalControl.CreatePipeLineStyle3D(); } if (lineStyle.ArrowStyle == null) { var arrowStyle = globalControl.CreateArrowStyle(); var arrowColor = globalControl.CreateColorRGBA(); arrowColor.setValue(255, 0, 255, 0); arrowStyle.BodyWidth = 2; arrowStyle.BodyLen = 6; arrowStyle.HeadWidth = 8; arrowStyle.HeadLen = 10; arrowStyle.OutlineVisible = true; arrowStyle.OutlineColor = arrowColor; arrowStyle.Speed = 25; arrowStyle.Play(); lineStyle.ArrowStyle = arrowStyle; lineStyle.ArrowVisible = visible; } lineStyle.ArrowVisible = visible; feat.Geometry.Style = lineStyle; } } globalControl.Refresh(); } }, showSelectedMarkers: function (roadName) { var layerLiquid = Gis.getGlobalControl().Globe.Layers.GetLayerByCaption(Gis.getLayerLiquid()); if (layerLiquid) { layerLiquid.Visible = true; var features = layerLiquid.GetAllFeatures(); for (var i = 0; i < features.Count; i++) {//显示或隐藏marker图标 var feature = features.Item(i); if (feature.Description.split(',').length >= 4) { var road = feature.Description.split(',')[3]; if (road.indexOf(roadName) !=-1) { feature.Visible = true; continue; } } feature.Visible = false; } globalControl.Refresh(); } } // pipelineLiuXiang: function () { // for (var i = 0; i < globalControl.Globe.Layers.Count; i++) { // var layer = globalControl.Globe.Layers.Item(i); // var feats = layer.GetAllFeatures(); // for (var j = 0; j < feats.Count; j++) { // var feat = feats.Item(j); // if (feat.Geometry.Type == 302) { // var lineStyle = feat.Geometry.Style; // if (lineStyle == null) { // lineStyle = globalControl.CreatePipeLineStyle3D(); // } // if (lineStyle.ArrowStyle == null) { // var arrowStyle = globalControl.CreateArrowStyle(); // var arrowColor = globalControl.CreateColorRGBA(); // arrowColor.setValue(255, 69, 0, 255); // arrowStyle.BodyWidth = 2; // arrowStyle.BodyLen = 6; // arrowStyle.HeadWidth = 8; // arrowStyle.HeadLen = 10; // arrowStyle.OutlineVisible = true; // arrowStyle.OutlineColor = arrowColor; // arrowStyle.Speed = 25; // arrowStyle.Play(); // lineStyle.ArrowStyle = arrowStyle; // lineStyle.ArrowVisible = false; // } // lineStyle.ArrowVisible = !lineStyle.ArrowVisible; // feat.Geometry.Style = lineStyle; // } // } // } // globalControl.Refresh(); // } } }();