how to draw a line from the center of a Circle to the edge given an angle.

247 views
Skip to first unread message

skrite

unread,
Dec 1, 2011, 1:47:12 PM12/1/11
to google-map...@googlegroups.com
Hey all

I need to draw a circle with a line that goes from the center to the edge of the circle at a certain angle. I know that i can draw to the exact North, South, East, and West using the getNorthEast() function and such, and use the difference to draw the other side.
However, i need to know how to draw the line if the angle is not 0, 90, 180, or 270 degrees. If i know the lat,long of the center, and i know the radius in meters (what i need to get a circle on Google Maps), what can i use to get the lat,long of a line at X angle?

Oh, and if it matters, the circles are only about 2 miles across the Diameter.

Thanks for any tips.

skrite

Rossko

unread,
Dec 1, 2011, 3:32:56 PM12/1/11
to Google Maps JavaScript API v3
> I need to draw a circle with a line that goes from the center to the edge
> of the circle at a certain angle.

So, ignoring the circle, you want to draw a line from 'centre' to a
second point at bearing 'x' and distance 'r'
See
http://www.movable-type.co.uk/scripts/latlong.html
or use the geometry library computeOffset()
http://code.google.com/apis/maps/documentation/javascript/geometry.html#Distance

Marcelo

unread,
Dec 1, 2011, 4:20:59 PM12/1/11
to Google Maps JavaScript API v3
This example:
http://maps.forum.nu/temp/gm_bearing.html

is API V2, but the math to calculate the angles is version agnostic.
You can drag the markers to redraw.

--
Marcelo - http://maps.forum.nu
--

skrite

unread,
Dec 2, 2011, 12:20:13 AM12/2/11
to Google Maps JavaScript API v3
That geometry library was exactly what i needed. Thanks very much to
all of you.
-shawn

On Dec 1, 2:32 pm, Rossko <ros...@culzean.clara.co.uk> wrote:
> > I need to draw a circle with a line that goes from the center to the edge
> > of the circle at a certain angle.
>
> So, ignoring the circle, you want to draw a line from 'centre' to a
> second point at bearing 'x' and distance 'r'

> Seehttp://www.movable-type.co.uk/scripts/latlong.html
> or use the geometry library computeOffset()http://code.google.com/apis/maps/documentation/javascript/geometry.ht...

Reply all
Reply to author
Forward
0 new messages