Map.Render method

Mar 31, 2007 at 10:03 PM
Can we please add a Map.Render method to make the Map object more extensible. This is a small but very useful change. Thank you.

/// <summary>
/// Renders the map to a graphics object
/// <param name="g">The graphics object to render to</param>
/// </summary>
public void Render(System.Drawing.Graphics g)
{
if (Layers == null || Layers.Count == 0)
throw new InvalidOperationException("No layers to render");

g.Transform = this.MapTransform;
g.Clear(this.BackColor);
g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
int SRID = (Layers.Count > 0 ? Layers0.SRID : -1); //Get the SRID of the first layer
for (int i = 0; i < _Layers.Count; i++)
{
if (_Layersi.Enabled && _Layersi.MaxVisible >= this.Zoom && _Layersi.MinVisible < this.Zoom)
_Layersi.Render(g, this);
}
if (MapRendered != null) MapRendered(g); //Fire render event
}

/// <summary>
/// Renders the map to an image
/// </summary>
/// <returns></returns>
public System.Drawing.Image GetMap()
{
if (Layers == null || Layers.Count == 0)
throw new InvalidOperationException("No layers to render");

System.Drawing.Image img = new System.Drawing.Bitmap(this.Size.Width, this.Size.Height);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
Render(g);
g.Dispose();
return img;
}