This function should create a 100 x100 rectangle around the center (LatLng) that you pass to it.
function setRectangle(center){
var scale = Math.pow(2,map.getZoom());
var proj = map.getProjection();
var wc = proj.fromLatLngToPoint(center);
var bounds = new google.maps.LatLngBounds();
var sw = new google.maps.Point(((wc.x * scale) - 50)/ scale, ((wc.y * scale) - 50)/ scale);
bounds.extend(proj.fromPointToLatLng(sw));
var ne = new google.maps.Point(((wc.x * scale) + 50)/ scale, ((wc.y * scale) + 50)/ scale);
bounds.extend(proj.fromPointToLatLng(ne));
var opts = {
bounds: bounds,
map: map,
editable:true
}
var rect = new google.maps.Rectangle(opts);
}
source
share