SharpMap学习6-模拟数据流-数据显示

数据显示最终归结为Map对象的自我绘制

image

 

最终通过GetMap对象返回一个Image对象来完成:

public Image GetMap()
{
    if (this.layers == null || this.layers.Count == 0)
    {
        throw new InvalidOperationException("没有图层信息");
    }
 
    Image img = new Bitmap(this.mapSize.Width, this.mapSize.Height);
    Graphics g = Graphics.FromImage(img);
    g.Clear(this.backColor);
    g.PageUnit = GraphicsUnit.Pixel;
 
    foreach (VectorLayer layerItem in this.layers)
    {
        if (layerItem != null)
        {
            layerItem.DrawLayer(g, drawingStyle);
        }
    }
 
    g.Dispose();
    return img;
}

你可能感兴趣的:(map)