[OpenLayers-Users] Circle Function

Arnie Shore ashore3 at verizon.net
Thu Apr 30 08:12:33 EDT 2009


Here's one I use with GMaps - xlation of the last line needed:

            function drawCircle(lng,lat,radius) {             // e.g., 
drawCircle(-87.628092,41.881906,2);
                var cColor = "#3366ff";
                var cWidth = 2;
                var Cradius = radius;
                var d2r = Math.PI/180;
                var r2d = 180/Math.PI;
                var Clat = (Cradius/3963)*r2d;
                var Clng = Clat/Math.cos(lat*d2r);
                var Cpoints = [];
                for (var i=0; i < 33; i++) {
                    var theta = Math.PI * (i/16);
                    Cx = lng + (Clng * Math.cos(theta));
                    Cy = lat + (Clat * Math.sin(theta));
                    var P = new GPoint(Cx,Cy);                // note 
long, lat order
                    Cpoints.push(P);
                    };
                map.addOverlay(new GPolyline(Cpoints,cColor,cWidth));
                }
AS

On Thu, Apr 30, 2009 at 07:53:17AM +0200, Kenny wrote:
>> Hi Guys,
>>
>>  
>>
>> I have been trying for ages and can't seem to get this working,
>>
>>  
>>
>> Does anyone have a simple function for drawing a circle?
>>     




More information about the Users mailing list