得到某点的缓冲区并画圆
2009-09-06 00:00:00 来源:WEB开发网然后我们得到像素与实地距离比,如下:
Js代码
//像素与实地距离比
getScale: function(){
var map = webmap.getMap();
var x1 = map.toScreenX(map.XMin);
var x2 = map.toScreenX(map.XMax);
var y1 = map.toScreenY(map.YMin);
var y2 = map.toScreenY(map.YMax);
geoDis = map.distance(x1, y1, x2, y1);
scepx = map.Width;
return parseFloat(scepx)/(parseFloat(geoDis)*100);
}
接着我们写出画圆接口,调用这个接口就可以把一个圆对象放到webmap的全局数组displayed_circle里,如下:
Js代码
//画圆接口(缓冲区时用)
setDisplayCircle: function(args){
function setcircle(left,top,width,height,showColor,showTitle,clickFun,circleProp){
var o = new Object();
o.left = left;
o.top = top;
o.width = width;
o.height = height;
o.showColor = showColor;
if(showTitle)
o.showTitle = function(){Tip(showTitle)};
if(clickFun)
o.clickFun = clickFun;
if(circleProp)
o.circleProp = circleProp;
webmap.displayed_circle[webmap.displayed_circle.length] = o;
}
setcircle(args.left,args.top,args.width,args.height,args.showColor||'red',args.showTitle,args.clickFun,args.circleProp);
}
更多精彩
赞助商链接