ArcGIS Server点线面查询闪烁
基本思路:
- 首先做查询,按条件查找出地理信息DoSearch(string txtvalue)
- 在服务器端将经纬度坐标转换为屏幕坐标,并且用回调方式向客服端的二维数组数组写入给点经纬度以及其他信息
//将点的经纬度坐标存入数组中,以备刷新地图时重绘各点
string ptcollection=" ptcollection["+i+"]=new Array();";
ptcollection +="ptcollection["+i+"][0]="+geomPt.X+";";
ptcollection += "ptcollection["+i+"][1]="+geomPt.Y+";";
ptcollection += "ptcollection[" + i + "][2]='" + mc + "';";
i++;
CallbackResult ptc = new CallbackResult(null, null, "javascript", ptcollection);
Map1.CallbackResults.Add(ptc);
//将经纬度坐标转化为屏幕坐标
System.Drawing.Point pt= geomPt.ToScreenPoint(Map1.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToScreen));
- 在客服端以gif图片绘制出各点(DrawPt(x,y,mc)),其中线取中点,面取的是包络线矩形的中点
function DrawPt(x,y,mc)
{
//动态获取点的ID号
var id=document.body.getElementsByTagName("pt").length;
var pt=document.createElement("pt");
pt.style.position="absolute";
pt.style.left=x;
// pt.style.background="green";
pt.style.top=y;
pt.style.zIndex=110;
pt.setAttribute("align","center");
pt.onclick = function(){pointClick1(mc,x,y)};
pt.id=id;
pt.value=mc;
// pt.style.visibility="hidden";
document.body.appendChild(pt);
document.getElementById('divCache').style.display='none';
}
4. 做地图移动,放大缩小时gif图片跟着地图移动
function RedirectToScreen(mapxmax,mapxmin,mapymax,mapymin)
{
document.getElementById("div").style.visibility="hidden";
document.getElementById('divCache').style.display='';
// document.all.<%=tableCache.ClientID%>.style.visibility="visible";
if(document.body.getElementsByTagName("pt").length!='0')
{
var ptCount=document.body.getElementsByTagName("pt").length;
//首先删除以前所有的点
for(var i=0;i<ptCount;i++)
{
var img=document.getElementById(i);
document.body.removeChild(img);
}
}
var screenWidth=document.body.clientWidth;
var screenHeight=document.body.clientHeight;
for(var i=0;i<ptcollection.length;i++)
{
var x=ptcollection[i][0];
var y=ptcollection[i][1];
var mc=ptcollection[i][2];
if(x<mapxmax&&x>mapxmin&&y<mapymax&&y>mapymin)
{
screenx=parseInt((screenWidth/Math.abs(mapxmax-mapxmin))*Math.abs(x-mapxmin));
screeny=parseInt(screenHeight-(screenHeight/Math.abs(mapymax-mapymin))*Math.abs(y-mapymin));
DrawPt(screenx,screeny,mc);
}
}
document.getElementById('divCache').style.display='none';
}
- 控制图片只有在地图范围内时才显示if(x<mapxmax&&x>mapxmin&&y<mapymax&&y>mapymin)
缺点(不足):由于线和面用点绘制闪烁很慢,所以这里以中点代贴,以待改进