Brady
A moan, a groan, my life story and how me, a technically minded person just can't seem to fit in with anybody.

Google Maps API Javascript V3 – Place Km/Mile radius/circle around point

So Google has released V3 of their Google Maps API and it appears that they have stripped out a number of useful functions that I’ve found myself using in V2. Apparently these functions have been stripped out to make a more lightweight and compact API for better performance for mobile devices. This is great but now you have to write your own function that Google has taken out.

So would you like to draw a radius around on a point on a Google map? Well I do and I managed it in the V2 API using a Google function called distanceFrom() and some custom code but now that function has been stripped out in v3. Anyway I’ve rewritten my code to do this in the V3 API. Take a look: http://pastebin.com/DnLqzMZx

This requires the Google Maps API and also the latlong JS script from Movable Type. To use simply call the function drawCircle() sending your Google longitude and latitude cords and the mile radius. If you want to use Km then comment out or delete the bit of code highlighted.

Oh and you can send some other variables too if you don’t like the default colours and settings.

Example usage: http://l3rady.com/wp-content/uploads/2010/09/mapexample.html