Pages

星期二, 1月 08, 2008

sharpmap rendermap

SharpMap.Map myMap;
private void button2_Click(object sender, EventArgs e)
{
myMap = new SharpMap.Map(new Size(400, 300));
myMap.MinimumZoom = 100; //Minimum zoom allowed
myMap.BackColor = Color.White; //Set background
myMap.Center = new SharpMap.Geometries.Point(216091, 2671943); //Set center of map
myMap.Zoom = 50000; //Set zoom level
myMap.Size = new System.Drawing.Size(600, 600); //Set output size

//add shapefile layer
SharpMap.Layers.VectorLayer layWorld = new SharpMap.Layers.VectorLayer("World");
//Specifing true will save the spatial index to a file which will make it load quicker the next time
layWorld.DataSource = new SharpMap.Data.Providers.ShapeFile(@"D:\WilJoey\TaiwanData(67)\tccRoad.shp", true);
myMap.Layers.Add(layWorld);
myMap.ZoomToExtents();

//Render the map
System.Drawing.Image imgMap = myMap.GetMap();
this.pictureBox1.Image = imgMap;
}

0 意見: