您得告诉清楚我您想干嘛,才好帮你解决问题哈。
比如上次您问的问题,我跟您回复思路您都是不会的,回复我的东西跟我告诉您的东西是根本没关系,我最后都把关键的代码写出来啦,您都还要要求远程,这样一味的要求我们远程不是正确解决问题的办法哦。关键是您要理解,理清思路哈。
我还是建议您多看一些例子学习一下:
http://support.supermap.com.cn:8090/iserver/iClient/for3D/plugin/samplecode/default.html
先运行范例看看情况,然后看看源代码,理解一下那些接口,比如怎么打开场景,怎么又往跟踪层添加对象,怎么获取了跟踪层的对象。您花点时间学习点,基础的东西多好。
这个是用的你们的js画的框
//扩展绘制矩形Action SuperMap.Web.UI.Action3Ds.DrawRectangleAction = function(_sceneControl,drawComplete) { SuperMap.Web.UI.Action3Ds.DrawRectangleAction.initializeBase(this); this._name = "DrawRectangleAction"; this._sceneControl = _sceneControl; this.drawComplete = drawComplete; this._type = SuperMap.Web.UI.Action3Ds.SceneActionType.POINTSELECT; }; //定义绘制矩形Action原型 SuperMap.Web.UI.Action3Ds.DrawRectangleAction.prototype = { drawComplete:null, drawEnd:true, isDrawing:false, point3D:null, geoBoundObj:null, boundsStr:"", point3Ds:null, dispose : function() { }, onMouseUp : function(e) { }, onMouseDown : function(e) { if (this.drawEnd) { this.point3D = new SuperMap.Web.Core.Point3D(e.get_longitude(), e.get_latitude(), 0); this.point3Ds = new SuperMap.Web.Core.Point3Ds(); this.isDrawing = true; this.drawEnd = false; this.point3Ds.add(new SuperMap.Web.Core.Point3D(e.get_longitude(), e.get_latitude(), 0)); this.boundsStr = e.get_longitude() + "," + e.get_latitude() + ";"; } else { this.drawEnd = true; // 结束绘制 this.isDrawing = false; // 绘制状态变为 false this.point3Ds.add(new SuperMap.Web.Core.Point3D(e.get_longitude(), e.get_latitude(), 0)); this._sceneControl.set_sceneAction(new SuperMap.Web.UI.Action3Ds.Pan(this._sceneControl)); // var startPoint = this.point3Ds.get_item(0); // var endPoint = this.point3Ds.get_item(1); // this.boundsStr += endPoint.x + "," + startPoint.y + ";" + endPoint.x // + "," + endPoint.y + ";" + startPoint.x + "," + endPoint.y // + ";"; // if(this.drawComplete){this.drawComplete(this.boundsStr);} if(this.drawComplete){this.drawComplete(this.point3Ds);} } }, onMouseMove : function(e) { if (this.isDrawing && this.isDrawing!= null) { var pnt1 = this.point3D; pnt1.z = e.get_altitude(); var pnt3 = new SuperMap.Web.Core.Point3D(e.get_longitude(), e .get_latitude(), e.get_altitude()); var pnt2 = new SuperMap.Web.Core.Point3D(pnt1.x, pnt3.y, e .get_altitude()); var pnt4 = new SuperMap.Web.Core.Point3D(pnt3.x, pnt1.y, e .get_altitude()); var pnt3Ds = new SuperMap.Web.Core.Point3Ds(); pnt3Ds.add(pnt1); pnt3Ds.add(pnt2); pnt3Ds.add(pnt3); pnt3Ds.add(pnt4); var geoRegion = new SuperMap.Web.Core.GeoRegion3D(); geoRegion.addPart(pnt3Ds); var feature = new SuperMap.Web.Core.Feature3D(); feature.set_geometry(geoRegion); this.geoBoundObj = geoRegion; var style = new SuperMap.Web.Core.Style3D(); style.set_fillForeColor(new SuperMap.Web.Core.Color(255, 255, 0,150)); style.set_lineColor(new SuperMap.Web.Core.Color(255, 255, 0, 255)); style.set_lineWidth(1); style.set_altitudeMode(0); feature.set_style3D(style); var scene = this._sceneControl.get_scene(); scene.get_trackingLayer3D().removeAll(); // 删除跟踪图层上的图像 scene.get_trackingLayer3D().add(feature, "region"); scene.get_trackingLayer3D().set_isVisible(true); scene.get_trackingLayer3D().refresh(); } } }; //注册Action类型 SuperMap.Web.UI.Action3Ds.DrawRectangleAction.registerClass('SuperMap.Web.UI.Action3Ds.DrawRectangleAction', SuperMap.Web.UI.Action3Ds.SceneAction, Sys.IDisposable);
用的这个js画的框,不知道怎么调用,这个框的对象。你给看看,
scene.get_trackingLayer3D().add(feature, "region");
很明显,在跟踪层加了一个名字叫“region”的对象,获取它很简单啊。昨天就告诉您方法了:
http://ask.supermap.com/9506
我在这再贴一次:
index=instanceOfTrackingLayer3D.indexOf(String)获取索引号。 然后var resultVar = instanceOfTrackingLayer3D.get_item(index);
instanceOfTrackingLayer3D是指跟踪层。
......
???这是添加对象啊,不是获取对象啊。你feature都没初始化,怎么有值?
您查一下帮助文档哈,或者是我们在线范例都有的,只要稍微花点时间看一下就明白的。
这个里面的获取跟踪层对象范例。
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> " + "<a class='webixbtn_nor' href='javascript:void(0)' onclick='query(" + (_pageIndex>1?(_pageIndex-1):1) + ");'>上一页</a> " + "<a class='webixbtn_nor' href='javascript:void(0)' onclick='query(" + ((_pageIndex>totalPageCount-1)?(totalPageCount):(_pageIndex+1)) + ");'>下一页</a> " + "<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> 第<input type='text' id='txtPageNo' style='width:25px;' value='" + _pageIndex + "'/>/" + totalPageCount + "页 </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); }
这个代码那一个方法是获取值的