﻿// JScript File
        function AddCircle(loc, radius, color, width, photo, title, customicon)
        {
            var R = 6371; // earth's mean radius in km
            var lat = (loc.Latitude * Math.PI) / 180; //rad
            var lon = (loc.Longitude * Math.PI) / 180; //rad
            var d = parseFloat(radius)/R;  // d = angular distance covered on earth's surface
            var locs = new Array();
            for (x = 0; x <= 360; x++) 
            { 
                var p2 = new VELatLong(0,0)            
                brng = x * Math.PI / 180; //rad
                p2.Latitude = Math.asin(Math.sin(lat)*Math.cos(d) + Math.cos(lat)*Math.sin(d)*Math.cos(brng));
                p2.Longitude = ((lon + Math.atan2(Math.sin(brng)*Math.sin(d)*Math.cos(lat), Math.cos(d)-Math.sin(lat)*Math.sin(p2.Latitude))) * 180) / Math.PI;
                p2.Latitude = (p2.Latitude * 180) / Math.PI;
                locs.push(p2);
            }
            var poly = new VEShape(VEShapeType.Polyline,locs);
            poly.SetLineColor(color)
            poly.SetLineWidth(width)
            poly.SetPhotoURL(photo);
            poly.SetTitle(title);
            poly.SetCustomIcon(customicon); 
           return poly; 
        }


