The map control is a Windows Forms control designed to display vector, raster and image data. The Map will be one of the primary tools that appears in the toolbox from the controls library. The layers inside of the map are organized in the
"MapFrame" class. This class has all of the necessary information needed to render the shapes, images and raster files to the map. This includes the symbology to use for each layer, as well as any dependent labeling layers. At this time the
Map is designed purely as a two dimensional control and uses GDI+ graphics in order to do all the drawing. This makes it portable to other operating systems with the help of Mono. An inheritance heirarchy of layers is used, and the top level
actually does the drawing. The important classes for controling symbology are MapPointLayer, MapPolygonLayer, MapLineLayer, MapImageLayer, and MapRasterLayer. These will be created automatically by adding an appropriate dataset to the map via Map.Layers.Add(myDataSet).
The important classes for opening files so that you can add content to the map programmticaly are the FeatureSet, Raster, and ImageData classes. These support open methods and will store the appropriate IFeatureSet, IRaster or IImageData implementation
for that file type internally.
Adding the Map
To add the control, use "Choose Items" from the toolbox to choose the items from DotSpatial.Controls.dll. You may have to use the browse option and navigate to the location in your project folders where the DotSpatial.Controls.dll is found.
Once the map appears in your toolbox, adding the map to an application is as easy as drag and drop after that. Even without writing a line of code, .shp files or certain image and raster files can be dragged as file items and dropped onto the map. To enable
navigation, you can control the property on the map called "FunctionMode", which lets you pick from a limited set of built in functions.
Frequently Asked Questions
- When I load a shapefile from a file, why don't my changes to the Features show up in the map?
- The FeatureSet uses an index mode to improve rendering performance. Call InitializeVertices() after making edits.
- Can I use the map in my web application
- Maybe, sort of, but this project is not optimized for use as a web viewer. We are recommending consideration of SharpMap or other open frameworks for the map display aspects in a web context as we have not yet developed a suitable web map control
for this framework. Technically, the rendering will work in Asp.Net, but we rely on persistent memory objects, which is not ideal for web servers, and we have not designed anything that would allow you to easily drag and drop a control into your web