atom feed3 messages in com.googlegroups.google-web-toolkitRe: draw circle without GWT (radius k...
FromSent OnAttachments
atpco81Oct 6, 2008 8:21 am 
Eric AyersOct 6, 2008 10:07 am 
atpco81Oct 7, 2008 1:12 am 
Subject:Re: draw circle without GWT (radius known)
From:Eric Ayers (zun@google.com)
Date:Oct 6, 2008 10:07:25 am
List:com.googlegroups.google-web-toolkit

Hi Giorgio,

It doesn't look like you are using the Google Web Toolkit (GWT),<http://code.google.com/webtoolkit>but straight JavaScript.

Searching the Maps group <http://groups.google.com/group/Google-Maps-API>might be of some help, but keep in mind that the Maps forum has some posting guidelines you should check out before posting a message there.

On Mon, Oct 6, 2008 at 11:21 AM, atpco81 <gpo@gmail.com> wrote:

Hi all,

I'm a newbie and this could be a very simple question: How could I draw a circle in a maps if I know its center and radius?

I use JS and I do a circle using the distance from two different points as, but I want to use a function like this example: http://maps.forum.nu/gm_sensitive_circle2.html I have been trying to work with this function but it doesn't work!

function drawCircleFromRadius(){

if (circleLine) { map.removeOverlay(circleLine); } var bounds = new GLatLngBounds(); var circlePoints = Array(); centerPoint= center.getPoint(); map.setCenter(centerPoint);

with (Math) { circleRadius= (radius/1000); //km var d = circleRadius/6378.8; // radians var lat1 = (PI/180)* centerPoint.lat(); // radians var lng1 = (PI/180)* centerPoint.lng(); // radians

for (var a = 0 ; a < 361 ; a++ ) { var tc = (PI/180)*a; var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)); var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y)); var x = ((lng1-dlng+PI) % (2*PI)) - PI ; // MOD function var point = new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/ PI))); circlePoints.push(point); bounds.extend(point); }

if (d < 1.5678565720686044) { circle = new GPolygon(circlePoints, '#000000', 2, 1, '#000000', 0.25); } else { circle = new GPolygon(circlePoints, '#000000', 2, 1); } map.addOverlay(circle);

map.setZoom(map.getBoundsZoomLevel(bounds)); } }

Is it a problem of Google API version(I use the v.2.x)? Have you got another examples ?