首页 / 浏览问题 / 云GIS / 问题详情
如何将查询结果以表格形式显示出来?
13EXP 2017年05月17日
通过关联查询,除了将结果高亮显示在地图上,其余信息想通过表格显示出来,怎么实现?求赐教

1个回答

您好,您可以参考一下我写的这段代码,思路其实和数组的遍历输出是一个道理,希望对您有帮助:

function processCompleted(queryEventArgs){ 
					 var result = queryEventArgs.result;
						if (result && result.totalCount>0) {
							  var resultTable="";
							  for (var i =0;i<result.recordsets.length;i++) {
									if (result.recordsets[i].features) {
										var arrFields = new Array();
										var intFieldCount=result.recordsets[i].fields.length;
										resultTable +="<table id='datatable' align='left' style='position:relative;width:300px;height:300px;overflow-y:auto;' border='1'>";
										var strTableHead="";
											for(var n=0;n<intFieldCount;n++)
											{   var fieldName=result.recordsets[i].fields[n];
												strTableHead +="<td>";
												strTableHead +=fieldName;
												arrFields.push(fieldName);
											}
											strTableHead +="<td>";
											strTableHead +="<input type='submit' value='refresh' >";
										    resultTable +="<tr>"+strTableHead+"</tr>";
											for(var k=0;k<result.recordsets[i].features.length;k++)
											{  var point = result.recordsets[i].features[k].geometry,
											   size = new SuperMap.Size(22, 20),
											   offset = new SuperMap.Pixel(-(size.w / 2), -size.h),
											   icon2 = new SuperMap.Icon("../theme/images/marker-gold.png", size, offset);
											   var feature=new SuperMap.Feature.Vector();
											   feature=result.recordsets[i].features[k]; 
											   var marker=new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon2);
											   marker.chao=feature;
											   markerLayerSQL.addMarker(marker);
                                               marker.events.on({//注册点击事件的处理方法
                                                                  "mouseover":openInfoWin,
                                                                  "mouseout": setTimeout111,
                                                                  "scope": marker
                                                                 });
											   resultTable += "<tr>";
												for(var j=0;j<intFieldCount;j++){
													resultTable +="<td>";
													resultTable += feature.attributes[arrFields[j]];
													if (j%2==1){
													  resultTable +="<td>";
													  resultTable +="<input type='checkbox' >";
													}
													resultTable +="</td>";
													
												}
												resultTable +="</tr>";
											}
									}
							  }
						}
						else{ resultTable="<p>无查询结果</p>";} 
						document.getElementById("queryResultPanel").innerHTML=resultTable;
						
				    }

程yan
1
1,695EXP 2017年05月17日
...