0&&points.length>=3)
AddPolylines(lines,GreatCirclePoints(points[i-1],points[i]),lineColor,lineWidth);}
if(points.length>=2)
AddPolylines(lines,GreatCirclePoints(points[points.length-1],points[0]),closerColor,lineWidth);if(points.length>=3)
{}
var smallFontOpen='';var fontClose='';var mapInst='Drag the map with your mouse, or double-click to center.';var clickInst='Click on the map to place points.';var html=smallFontOpen+mapInst+''+clickInst;areaDiv.innerHTML=' ';if(points.length<=2)
html+='
Once you have placed at least three points, the enclosed area will be computed.';else
{html+='
The enclosed area is shown below.';var areaMeters2=SphericalPolygonAreaMeters2(points);if(areaMeters2<1000000.0)
areaMeters2=PlanarPolygonAreaMeters2(points);areaDiv.innerHTML=smallFontOpen+Areas(areaMeters2)+fontClose;}
html+=fontClose;instructionsDiv.innerHTML=html;}
function AddPolylines(lines,ps,lineColor,lineWidth)
{var line=new GPolyline(ps,lineColor,lineWidth);lines.push(line);map.addOverlay(line);for(var i=0;i420.0)
{totalAngle=points.length*360.0-totalAngle;sphericalExcess=totalAngle-planarTotalAngle;}
else if(sphericalExcess>300.0&&sphericalExcess<420.0)
{sphericalExcess=Math.abs(360.0-sphericalExcess);}
return sphericalExcess*radiansPerDegree*earthRadiusMeters*earthRadiusMeters;}
function Angle(p1,p2,p3)
{var bearing21=Bearing(p2,p1);var bearing23=Bearing(p2,p3);var angle=bearing21-bearing23;if(angle<0.0)
angle+=360.0;return angle;}
var clicked=false,doubleClicked;function MapClick(overlay,point)
{try
{if(overlay==null&&point!=null)
{if(clicked)
doubleClicked=true;else
{clicked=true;doubleClicked=false;setTimeout(MakeCaller(MapClickLater,point),250);}}}
catch(e)
{GLog.write('MapClick:\n'+Props(e));}}
function MapClickLater(point)
{try
{if(!doubleClicked)
{points.push(point);Display();}
clicked=false;}
catch(e)
{GLog.write('MapClickLater:\n'+Props(e));}}
function MarkerClick(pointIndex)
{try
{RotatePoints(pointIndex+1);Display();}
catch(e)
{GLog.write('MarkerClick:\n'+Props(e));}}
function RotatePoints(n)
{var t=[];for(var i=0;i0)
points.length--;Display();}
function ClearAllPoints()
{points=[];Display();}