[mapguide-users] RenderMap and map state as regards current extent

TravisBrannon tbrannon at geotechsystems.com
Wed Mar 18 08:44:49 EDT 2009

Hi folks,

I am using the RenderingService to generate a map based upon a center point
and a scale, yada yada yada.  I am wondering if after I call RenderMap,
passing in all required parameters (map object included), when I call
GetDataExtent on the Map will the returned extent reflect the extent of the
generated raster map image?   In other words is the state of the current
extent preserved for the life of the Map object after a call to RenderMap or
is it simply a one off?

Code is below (and thanks in advance):

public static MgByteReader GenerateMapByteReader(MgRenderingService
RenderingService, MgMap Map, MgEnvelope Envelope, int Width, int Height,
Color BaseColor, string ImageFormat)
            MgGeometryFactory factory = new MgGeometryFactory();
            double upperRightX = Envelope.UpperRightCoordinate.GetX();
            double lowerLeftX = Envelope.LowerLeftCoordinate.GetX();
            double upperRightY = Envelope.UpperRightCoordinate.GetY();
            double lowerLeftY = Envelope.LowerLeftCoordinate.GetY();
            double x = lowerLeftX + (Math.Abs(upperRightX - lowerLeftX) /
            double y = upperRightY - (Math.Abs(upperRightY - lowerLeftY) /
            MgCoordinate center = factory.CreateCoordinateXY(x, y);
            MgCoordinateSystemFactory csFactory = new
            MgCoordinateSystem cs = csFactory.Create(Map.GetMapSRS());
            double metersPerUnit =
            double metersPerPixel = 0.0254 / 96;
            double scale = 0.0;
            if (Height * (upperRightX - lowerLeftX) > Width * (upperRightY -
                scale = ((upperRightX - lowerLeftX)) * metersPerUnit / Width
* metersPerPixel;
                scale = ((upperRightY - lowerLeftY) * metersPerUnit) /
(Height * metersPerPixel);
            MgByteReader mapReader = RenderingService.RenderMap(Map, null,
center, scale, Width, Height, BaseColor, ImageFormat);
            /* Question relates to this line */
            MgEnvelope env = Map.GetDataExtent();
            return mapReader;

View this message in context: http://n2.nabble.com/RenderMap-and-map-state-as-regards-current-extent-tp2496957p2496957.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list