<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
//--------------
// Init
var lastFW = null;
var lastLD = null;
var lastobj = null;
var tintcolor = null;
var messageid = "";
var ifkey = false;
function Init() {
SGWorld.AttachEvent("OnLButtonClicked", OnLButtonClicked);
SGWorld.AttachEvent("OnFrame", OnFrame);
SGWorld.AttachEvent("OnSGWorldMessage", OnSGWorldMessage);
tintcolor = SGWorld.Creator.CreateColor(0, 255, 0, 125);
}
function OnSGWorldMessage(MessageID, SourceObjectID) {
try {
var cto = SGWorld.Creator.GetObject(SourceObjectID);
var layerid = cto.LayerID;
if (layerid == undefined)
return;
var layer = SGWorld.ProjectTree.GetLayer(layerid);
var layername = SGWorld.ProjectTree.GetItemName(layerid);
if (layername == "build_model" || layername == "Building_DL") {
if (ifkey) {
if (lastLD != null) {
lastLD.Show = 1;
}
SGWorld.ProjectTree.SetVisibility(layerid, 0);
ifkey = false;
return true;
}
if (lastFW != null) {
if (lastFW != cto) {
lastFW.Tint.abgrColor = 0x00000000;
}
lastFW = cto;
} else {
lastFW = cto;
}
if (cto.Tint.abgrColor == "" || cto.Tint.abgrColor == "0" || cto.Tint.abgrColor == 0x00000000 || cto.Tint.abgrColor == 0) {
cto.Tint = tintcolor;
// cto.Tint.abgrColor=0xff0000aa;
} else {
cto.Tint.abgrColor = 0x00000000;
}
} else if (layername == "poly_dl") {
}
} catch (e) {
}
}
function OnFrame() {
var mouseInfo = SGWorld.Window.GetMouseInfo()
//将平面坐标转换为球面坐标
var worldPst = SGWorld.Window.PixelToWorld(mouseInfo.x, mouseInfo.y, -1);
var type = worldPst.Type;
var focusID = worldPst.ObjectID;
if (type == "1" || type == "8192") {
try {
var cto = SGWorld.Creator.GetObject(focusID);
if (lastobj != null) {
if (lastobj != cto) {
lastobj.Tint.abgrColor = 0x00000000;
}
lastobj = cto;
} else {
lastobj = cto;
}
if (cto.Tint.abgrColor == "" || cto.Tint.abgrColor == "0" || cto.Tint.abgrColor == 0x00000000 || cto.Tint.abgrColor == 0) {
cto.Tint.abgrColor = 0x330000ff;
} else {
cto.Tint.abgrColor = 0x00000000;
}
} catch (e) {
if (lastobj != null) {
lastobj.Tint.abgrColor = 0x00000000;
}
}
} else {
if (lastobj != null) {
lastobj.Tint.abgrColor = 0x00000000;
}
}
}
function OnLButtonClicked(flag, x, y) {
var mouseInfo = SGWorld.Window.GetMouseInfo();
//将平面坐标转换为球面坐标
var worldPst = SGWorld.Window.PixelToWorld(mouseInfo.x, mouseInfo.y, -1);
var type = worldPst.Type;
var focusID = worldPst.ObjectID;
//alert(focusID);
if(focusID!=""){
var cto = SGWorld.Creator.GetObject(focusID);
/*
var data = new Array();
data.push('<table border=1><tbody>');
for (var i = 0; i < cto.FeatureAttributes.Count; i++) {
data.push('<tr>');
data.push('<th>' + cto.FeatureAttributes.Item(i).Name.toString() + ":" + '</th>');
data.push('<td>' + cto.FeatureAttributes.Item(i).Value.toString() + '</td>');
data.push('</tr>');
}
data.push('</tbody></table>');
*/
//动态的创建表格,注意innerHTML的本质是将标签里面的内容给替换掉。
var str = "";
str += '<table border=1><tbody>';
var count = cto.FeatureAttributes.Count;
if(count!=0){
for (var i = 0; i < count; i++) {
str +='<tr>';
str +='<th>' + cto.FeatureAttributes.Item(i).Name.toString() + ":" + '</th>';
str +='<td>' + cto.FeatureAttributes.Item(i).Value.toString() + '</td>';
str +='</tr>';
}
//var s = data.join('');
str += '</tbody></table>';
}
//alert(s);
document.getElementById('table').innerHTML = str;
}
}
function onunload() {
if (lastLD != null) {
try {
lastLD.Show = 1;
} catch (e) {
}
}
SGWorld.DetachEvent("OnFrame", OnFrame);
SGWorld.DetachEvent("OnSGWorldMessage", OnSGWorldMessage);
SGWorld.DetachEvent("OnLButtonClicked", OnLButtonClicked);
//SGWorld.DetachEvent("OnMButtonUp",OnMButtonUp);
}
</script>
<!--测试是否可以画线-->
<!--<script>-->
<!--function Init() {-->
<!--SGWorld.Command.Execute(1012,4);-->
<!--}-->
<!--</script>-->
</head>
<body leftmargin="0" topmargin="0" marginheight="0" style="border:0;overflow:auto;" id="body" οnlοad="Init()"
οnunlοad="onunload()">
<object id="SGWorld" classid="CLSID:3A4F9199-65A8-11D5-85C1-0001023952C1"></object>
<div id="table">
</div>
<!--<!–表格–>-->
<!--<table border="1" cellpadding="1" style="background-color: #E8E8E8;width: 100%;height: 300px">-->
<!--<colgroup>-->
<!--<col span="1" style="background-color:#E0E0E0">-->
<!--<col style="background-color:#F8F8F8">-->
<!--</colgroup>-->
<!--<tr>-->
<!--<th id="attr" colspan="2">Attributes</th>-->
<!--</tr>-->
<!--<tr>-->
<!--<th id="title_name">Name:</th>-->
<!--<td id="name_content">null</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<th id="x">X:</th>-->
<!--<td id="x_content">null</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<th id="y">Y:</th>-->
<!--<td id="y_content">null</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<th id="z">Z:</th>-->
<!--<td id="z_content">null</td>-->
<!--</tr>-->
<!--</table>-->
</body>
</html>
skyline属性查询
最新推荐文章于 2022-10-09 10:58:40 发布