From: Xin Zheng Date: 2008-01-16T21:26:23+09:00 Subject: Re: spatial search & search radius circumference with Geokit Andre Lewis wrote: > Hi Xin, here is an example of plotting a circle (from centerpoint and > radius) in Javascript : > http://www.ovationmarketing.com/GMaps/MapCircle.asp . You can find other > examples out there too by googling around. Thanks for the link Andre. This is a lot easier to understand than the xmaps (http://xmaps.busmonster.com/) code I was looking at. I have now converted this into Ruby. Most of the time the circle polygon I draw matches with the results returned from Geokit. But sometimes results fall outside of it. Here's my code: def circle_points(center_x, center_y, radius, quality = 3) points = [] radians = Math::PI / 180 0.step(360, quality) do |i| x = center_x + (radius * Math.cos(i * radians)) y = center_y + (radius * Math.sin(i * radians)) points << [x,y] end points end radius = miles * (360 / 24901.463) where 24901.463 is the circumference of Earth in miles I'm using. I took this from Wikipedia. Are you using the same algorithm? Are you using the same circumference? Thanks for helping! Xin -- Posted via http://www.ruby-forum.com/.