How to Create an Extension for DotSpatial Desktop Mapping GIS


DotSpatial is an open-source project that contains controls which can be used to manipulate and display geographic information. This article explains how to create a DotSpatial extension by using the online template. Though this template is for C#, you can do something similar in other .Net languages.

Downloading Visual Studio

There are several free IDEs available, namely SharpDevelop, MonoDevelop, and Visual Studio Express. None of these presently support the template, however, so you’ll need Visual Studio Professional or better. Notably, Visual C# 2010 Express should support this template if NuGet becomes available.

Creating a New Project

Start Visual Studio 2010 and open the New Project dialog (File, New, Project…). Click the Online Template Tab and search for DotSpatial.


Select the DotSpatial Plugin Template from the list of results, name your project and click OK.

After accepting any applicable license agreement, the template will download and install and your project will be created.


Once you have initially downloaded and installed the template, you can create new projects using this template without going online and searching. It will be listed along with your other installed templates. Also, if we update the template, you may be prompted by Visual Studio to update your copy of it.

Customizing the extension

The advantage of creating an extension is that it can be published to the public extension feed or opened in any supported application, such as MapWindow 6.

Let’s modify our extension so that it shows the number of layers presently open.

The code corresponding to the extension is in MyPlugin1.cs. Open this file and change “My Button Caption” to “Show Layer Count”.

Replace the comment in the ButtonClick event handler method with code so that a progress message is displayed when the menu item is clicked:

public void ButtonClick(object sender, EventArgs e)
    string message = String.Format("Number of Layers: {0}",
    App.ProgressHandler.Progress(null, 0, message);

Building and running

The template contains a number of NuGet packages and a sample executable so that you can build and run your project without any further ado! (Debug, Start Debugging) The plugin will be copied to the appropriate directory and you will be presented with a sample legend, toolbox, and map configuration.


Feel free to drop a layer onto the map or click the menu item that was created.



4 thoughts on “How to Create an Extension for DotSpatial Desktop Mapping GIS

  1. Pingback: Composing an Application by using Extensions « Mudnug

  2. Pingback: How to Customize Branding of MapWindow 6 « Mudnug

  3. I clicked to install the template and got this error: This extension cannot be installed because the following references are missing: – NuGet Package Manager. I downloaded the NuGet thingy from Microsoft and then installation of the DotSpatial template was successful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s