3维获取不到面的对象

0 投票
我需要获取面的对象金数据库查询数据
6月 27, 2017 分类:  732次浏览 | 用户: 安妮 (5 分)

1个回答

0 投票
请问用的什么产品?
6月 27, 2017 用户: 邹涛 名扬四海 (3,333 分)
前台调用提示feature为空

......

???这是添加对象啊,不是获取对象啊。你feature都没初始化,怎么有值?

您查一下帮助文档哈,或者是我们在线范例都有的,只要稍微花点时间看一下就明白的。

http://support.supermap.com.cn:8090/iserver/iClient/for3D/plugin/samplecode/default.html

这个里面的获取跟踪层对象范例。

http://support.supermap.com.cn:8090/iserver/iClient/for3D/plugin/samplecode/samplecode/samples/Query3D/Hittest.html

这是你们公司的人说的用这个js 就能获取范围,他只给了我代码没告诉我怎么调

function queryByRectangle(pageIndex) {
	if(!_bounds)return;
	var attributeFilter = getAttributeFilter();
	var strBounds = JSON.stringify(_bounds);
		if(pageIndex==null||typeof pageIndex == "undefined")
			pageIndex = 1;
		else if(pageIndex<0)
		pageIndex = parseInt(document.getElementById("txtPageNo").value);
		_pageIndex = pageIndex;
		var fromIndex = _pageSize * (_pageIndex - 1);
		var toIndex = _pageSize * _pageIndex - 1;
		var strURL = top.IserverSite+"/services/"+top.dataServicesName+"/rest/data/featureResults.json?returnContent=true&fromIndex=" + fromIndex + "&toIndex=" + toIndex;
		var xmlHttp;
		if(window.ActiveXObject)
		        xmlHttp = new ActiveXObject("MicroSoft.XMLHTTP");
		    else if(window.XMLHttpRequest)
        		xmlHttp = new XMLHttpRequest();
		var strPostString = '{\"datasetNames\":[\"' + top.dataSourcesName + ':' + top.dataSetName + '\"],\"getFeatureMode\":\"BOUNDS_ATTRIBUTEFILTER\",\"bounds\":'+strBounds+',\"attributeFilter\":\"'+ attributeFilter +'\"}';
			xmlHttp.open("POST", strURL, false);
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded;charset=UTF-8");
	    	xmlHttp.send(strPostString);
		var jsonResult = eval("[" + xmlHttp.responseText + "]");
		if(jsonResult==null||jsonResult.length<1||jsonResult[0].features.length<1){
			alert("没有查询到结果!");
			return;
		}
			xmlHttp=null;
		requestComplete(jsonResult[0]);
}

function requestComplete(jsonResult){
	top.clear();
	top.setBuildingAlpha(0);
		var strTableHTML = "<table class='tblContent' border='0' bordercolor='RGB(235,235,235)' style='' cellpadding='0' cellspacing='1'>"
		for(var i=0;i<jsonResult.features.length;i++){
		var strName = "";
		var SmID,SmX,SmY,SmZ;
		var arrPoints=[];
			for(var j=0;j<jsonResult.features[i].fieldNames.length;j++){
			if(jsonResult.features[i].fieldNames[j].toUpperCase()=="SMX" || jsonResult.features[i].fieldNames[j].toUpperCase()=="LONGITUDE")
			SmX = jsonResult.features[i].fieldValues[j];
			else if(jsonResult.features[i].fieldNames[j].toUpperCase()=="SMY" || jsonResult.features[i].fieldNames[j].toUpperCase()=="LATITUDE")
			SmY = jsonResult.features[i].fieldValues[j];
			else if(jsonResult.features[i].fieldNames[j].toUpperCase()=="SMZ" || jsonResult.features[i].fieldNames[j].toUpperCase()=="ALTITUDE")
			SmZ = jsonResult.features[i].fieldValues[j] == 0 ? 25 : jsonResult.features[i].fieldValues[j];
			else if(jsonResult.features[i].fieldNames[j].toUpperCase()=="SMID"){
			SmID = jsonResult.features[i].fieldValues[j];
	top.setQueryObjHighLight(SmID);
}
}
var showName = attributes["TYPE"]+"   "+attributes["REMARK"];
var attributes = formatAttributes(jsonResult.features[i]);
strTableHTML += "<tr><td style='max-width:35px;text-align:center;padding:5px;'><img title='定位到该设施' src='../../../images/marker/pin_red.png' style='cursor:pointer;' onmouseout='this.src=\"../../../images/marker/pin_red.png\";' onmouseover='this.src=\"../../../images/marker/pin_red.png\";' onclick='locateFeature(" + SmID + "," + SmX + "," + SmY + "," + SmZ + ");'/></td>";
strTableHTML += "<td style='color:#FFF;max-width:261px;' title=\'"+attributes["NAME"]+"\'>"+attributes["NAME"]+"</td>";
strName = attributes["TYPE"];
strTableHTML += "</td></tr>";
var flyToGeometry = i<jsonResult.features.length-1?false:true;
top.drawMarker(SmX, SmY, 10, top.serverUrl + top.siteName + "/images/marker/pin_red.png", strName, "marker", attributes["SMID"],flyToGeometry);
var marker = top.addMarker2D(attributes["SMID"], SmX, SmY, 0, -20, top.serverUrl + top.siteName + "/images/marker/pin_red.png", 31, 31, buildPopupContent(jsonResult.features[i]).contentHTML,attributes["SMID"]);
marker.icon.imageDiv.style.cursor = "pointer";
marker.icon.imageDiv.title = strName;
}
var totalPageCount = Math.ceil(jsonResult.featureCount / _pageSize);
strTableHTML += "<tr><td style='text-align:center;color:#FFF;' colspan='2'>共查询到<span style='color:#FF0000;'>" + jsonResult.featureCount + "</span>条结果</td></tr>"
+ "<tr><td style='text-align:center;' colspan='2'>"
+ "<a href='javascript:void(0)' class='webixbtn_nor' onclick='query(1);' onmouseon='changeobjcls(this, 1);' onmousedown='changeobjcls(this, 2);' onmouseup='changeobjcls(this, 1);' onmouseout='changeobjcls(this, 0);' style0='display:none;'>首页</a>&nbsp;"
+ "<a class='webixbtn_nor' href='javascript:void(0)' onclick='query(" + (_pageIndex>1?(_pageIndex-1):1) + ");'>上一页</a>&nbsp;"
+ "<a class='webixbtn_nor' href='javascript:void(0)' onclick='query(" + ((_pageIndex>totalPageCount-1)?(totalPageCount):(_pageIndex+1)) + ");'>下一页</a>&nbsp;"
+ "<a class='webixbtn_nor' href='javascript:void(0)' onclick='query(" + totalPageCount + ");' style0='display:none;'>末页</a></td></tr>"
+ "<tr><td style='text-align:center;' colspan='2'><a class='webixbtn_nor' href='javascript:void(0)' onclick='switchNum()'>转到</a>&nbsp;第<input type='text' id='txtPageNo' style='width:25px;' value='" + _pageIndex + "'/>/" + totalPageCount + "页&nbsp;</td></tr>"
strTableHTML += "</table>";
if(top.document.getElementById("queryresult"))
;
//	 top.hidediv("queryresult");
else
top.showdiv("./webpage/facility/query/queryresult.jsp","queryresult","350px","530px","150px","auto","auto","65px");
//	$("#main", top.document.getElementById("queryresult").contentWindow.document).html(strTableHTML);
setTimeout(function(){$("#main", top.document.getElementById("queryresult").contentWindow.document).html(strTableHTML);},1000);
}

这个代码那一个方法是获取值的

帮我看看行不
...