//这个类很奇怪,奇怪在于,居然没有任何地方调用它,也就是说,这段代码的存在毫无意义,可能是Google当时正在开发的功能吧
//看了一下,这个功能是Google的一个没有开发的功能,用来添加一个具有指向功能的标注,非常有意思,就是在某点上显示一个箭头标注,指向目标点,
//指向的箭头Google用了一系列的图片如下:
//http://www.google.com/intl/zh-CN_ALL/mapfiles/dir_0.png
//http://www.google.com/intl/zh-CN_ALL/mapfiles/dir_3.png
//http://www.google.com/intl/zh-CN_ALL/mapfiles/dir_6.png
// ………
// ………
// ………
//http://www.google.com/intl/zh-CN_ALL/mapfiles/dir_360.png
//那我就自作主张给它取名字叫GArrow吧
//这个类还是蛮有意思的,为什么不开放出来呢?
function GArrow(point,start,end)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.point=point;
this.start=start;
this.end=end
}
GArrow.prototype=new GOverlay();
GArrow.prototype.initialize=function(map)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.map=map;
};
GArrow.prototype.remove=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
var a=this.img;
if(a)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
deposeNode(a);
this.img=null
}
};
GArrow.prototype.copy=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
return new GArrow(this.point,this.start,this.end)
};
GArrow.prototype.redraw=function(a)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
if(!a)return;
var b=this.map;
var c=b.getCurrentMapType();
if(!this.img||this.mapType!=c)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.remove();
var d=this.getAngle();
this.img=CreateImage(getImageSrcByAngle(d),b.getPane(0),GPoint.ORIGIN,new GSize(24,24),true);
this.angle=d;
this.mapType=c
}
var d=this.angle;
var e=Math.floor(-12-12*Math.cos(d));//图片大小是24*24的
var f=Math.floor(-12-12*Math.sin(d));
var g=b.fromLatLngToDivPixel(this.point);
SetPosition(this.B,new GPoint(g.x+e,g.y+f))
//定位图片
};
//获得两点之间连线与竖直向上之间的角度(顺时针方向)
GArrow.prototype.getAngle=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
var a=this.map;
var b=a.fromLatLngToPixel(this.start);
var c=a.fromLatLngToPixel(this.end);
return Math.atan2(c.y-b.y,c.x-b.x)
};
//根据上面的方法求出的角度获取图片路径
function getImageSrcByAngle(a)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
var b=Math.round(a*60/Math.PI)*3+90;
while(b>=120)b-=120;
while(b<0)b+=120;
return getStaticImageUrl("dir_"+b)
};