One important thing is you have to make sure to include the geometry library when you declare your javascript for gmaps
I just did this, my goal was to draw a 1km box around a point.
ne = google.maps.geometry.spherical.computeOffset(latlng, 500, 0)
latlng is the original latlng object, 500 is the number of meters you want to go, 0 is the number of degrees from North that you want to move in. (0 goes straight up, 90 goes east, 180 south, 270 west)
ne is the resulting latlng
So to build a square around a point I did:
ne = google.maps.geometry.spherical.computeOffset(latlng, 500, 0)
ne = google.maps.geometry.spherical.computeOffset(ne, 500, 90)
se = google.maps.geometry.spherical.computeOffset(ne, 1000, 180)
sw = google.maps.geometry.spherical.computeOffset(se, 1000, 270)
nw = google.maps.geometry.spherical.computeOffset(sw, 1000, 0)
var box = new google.maps.Rectangle({
map:map,
strokeOpacity:5,
bounds:new google.maps.LatLngBounds(sw,ne)
});