DotSpatial Tutorial 1
DotSpatial Tutorial 1
Teva ~ Veluppillai
Page 1
Step 2: Add the DotSpatial reference and change the compile option.
2.1) Add the DotSpatial references
1. Right click over the project on the solution explorer and select the add reference from the
context menu.
2. Add the following 4 references from the downloaded folder. fig.5
DotSpatial.Controls.dll, DotSpatial.Data.dll, DotSpatial.Data.Forms.dll, DotSpatial.Symbology.dll
Teva ~ Veluppillai
Page 2
Teva ~ Veluppillai
Page 3
Teva ~ Veluppillai
Page 4
Fig.5 Select the .Net Framework 4 from the Advanced Compile Settings Window.
Teva ~ Veluppillai
Page 5
Step 3: Add the DotSpatial Controls into the Visual Studio Toolbox.
3.1) Creating a new Tab on the ToolBox window and adding the DotSpatial class library
Create a new project in C# and select the ToolBox on the standard menu bar. Right click on the ToolBox
window and choose "Add Tab" from the context menu. Fig.3 Enter the new tab name as DotSpatial. On
the DotSpatial tab right click and select the choose items from the context menu.
Click the Browse button on the Choose Tool Box Items window. Fig.4
Teva ~ Veluppillai
Page 6
Make sure the AppManager is checked on the Choose Toolbox Items window. fig.6
Teva ~ Veluppillai
Page 7
Map
Control
Page 8
Name
btnLoad
btnClear
btnZoomIn
btnZoomOut
btnZoomToExte
nd
btnPan
btnInfo
btnMeasure
btnSelect
btnNone
Text
&Load Map
&Clear Map
Zoom &In
Zoom &Out
Zoom to
&Extent
&Pan
In&fo
&Measure
&Select
&None
4.2) Use shortcut keys for the button click event. Ex: Load Map button's short cut key is Shift +
L. To implement this feature, on the properties window of the button select the Text property and use the
& sign in front of any letter. In the load button case, Text property should be &Load Map
5. Add a title label above the group box. Name of the label should be lblTitle and the text property of the
label is Basic Map Operations.
Step 5: Write the code for implementing the map operations.
1. Add the following namespace
C#.net
//Required namespace
using DotSpatial.Controls;
VB.net
'Required namespace
Imports DotSpatial.Controls
Teva ~ Veluppillai
Page 9
Page 10
Teva ~ Veluppillai
Page 11
3. To display the tool tip message for the buttons, add the following code in the form load event.
Double click over the form for getting the form load event code view.
Teva ~ Veluppillai
Page 12
Teva ~ Veluppillai
Page 13
Teva ~ Veluppillai
Page 14