Recently was asked by a user that the Zoom to Rectangle tool in Mapguide doesn't work. In investigating their statement, it turns out that when they were using the 'Zoom to Rectangle' tool they were drawing a rectangle that went precisely over top of the object of interest, and therefore was being cut off on the outer bounds.
In looking at the code base for the 'Zoom to Rectangle' function calculates the new mapscale based on the largest side of the rectangle, AND assumes the first x/y position of the rectangle is the top left (90% of the time it would be but some people will draw a rectangle from lower right to top left).
The following code adjusts the 'Zoom to Rectangle' function slightly so that no matter what order the rectangle is captured in (lower right to top left/top right to lower left/top left to lower right/etc), it resets the x1/y1 values to be the top left, and recalculates the shape of the zoom rectangle to roughly fit the shape of the mapframe. It does this by getting the larger edge of the zoom rectangle, and adjust the other edge by applying the ratio of width to height of the mapframe. In addition to the recalculate of the zoom rectangle shape, it puts a expands it by 5px, to ensure that the object being zoomed to fits in the mapframe and is not cut off.
To use this code replace the ExecuteRectangleTool() function in ajaxmappane.templ, with the one below.
Comments are appreciated. Jamie