This project has moved. For the latest updates, please go here.

Example 1: Adding 1 layer to the Map

In the step you will add a layer to the mapcontrol created in the first step of the tutorial.

1. Add a reference to SharpMap.dll if it's not already added

2. Open the code for the form by right-clicking the form and choose "View Code"

3. Add the following code to the constructor of the form

(The data: states_ugl.shp is located in the zip on the tutorial overview page)

 public partial class Form1 : Form
        public Form1()

            SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
            vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("path_to_data\\states_ugl.shp", true);
mapBox1.Refresh(); } }

4. Run the application and you should now see the US states in the map

5. Set the Active tool to Pan

mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;

6. Run the application again and you should now be able to pan and zoom (by scrolling the mouse-wheel) in the map

Last edited May 27, 2014 at 9:52 AM by petlof, version 10