Here is a basic idea using the Google Geometry library .
Remember to add a geometry library. It is separate from the Google map library.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"> </script>
usage example:
I have an example fiddle of this in action.
Bryan weaver
source share