+1-888-201-6088 | email@nevron.com
Nevron logo
Nevron word

Nevron Diagram for .NET Map Import - Using Maps in Diagrams


Nowadays the globalization process is stronger than ever and many companies sell products and services all over the world. That's why software applications in many areas need to provide geographical and mapping information to the end users. World's most popular format for storing such information is the ESRI shapefile. There are hundreds of freely available ESRI maps on the web and now you can easily take advantage of them using Nevron Diagram and its integrated mapping features. All you have to do is to put our diagramming component in your project and your mapping solution is just a few lines of code away.

Nevron Diagram for .NET Maps will enhance your .NET desktop or Web-based applications by adding intuitive, user-friendly and interactive Maps and geographical data, extending the Diagram to provide sophisticated graphs for your specific business needs.

How to add a map

To import maps in you diagrams just follow these simple steps:
1. Create an object of type NEsriMap that will host the geographical data.
2. Add the ESRI shapefiles you want to load one by one using the Add method of the map. The Add method returns the created shapefile in case you want to set some of its properties:
  • EnableZoomInRange - Gets/Sets whether the objects from the file should only be shown if the current zoom factor is in the Min/Max Zoom factor range specified by the MinShowZoomFactor and MaxShowZoomFactor properties.
  • NameColumn - Determines the data column from the DBF file to use for naming of the diagram elements that are created from this shapefile.
3. When finished adding shapefiles to the map, call the Read method to load the data.
4. Call the ImportShapes method to import the loaded shapes in the document. You can control the importing process using the ShapeImporter of the map that has the following properties:
  • PolygonsAsShapes, PolylinesAsShapes - determine whether to render the objects as shapes or as paths.
  • ImportInMultipleLayers - determines whether to import the data from each ESRI file into separate layer.
  • FeatureCreatedCallback - if you want to perform additional customization on each diagram element implement the INFeatureCreatedCallback interface and set it to this property.
Map Air Route Gal Detail

Fig. 1


The NMap class provides properties and methods that can help you adjust the appearance of any imported map. Let's take a look at them:
  • Parallels, Meridians - you can use these properties to set the way the geographic grid is rendered. For each collection of arcs you can set the way they are rendered (below or above the other map objects, or not rendered at all) and whether to label them or not.
  • Projection - allows you to specify the projection to use when importing the shapes (by default set to an Equirectangular projection). For more information about projections take a look at the Projections chapter.
  • FillRules - a collection of the fill rules for the map. Fill rules are used in conjunction with data attribute values to automatically colorize maps. This approach is perfect for generating color thematic maps. For example, a map of the world could be colorized using available population data, or sales numbers for each country. For more information about fill rules take a look at the Fill Rules chapter.

Data Binding

The data binding feature of Nevron Map allows you to bind map features to the columns of a database table. For example, by calling the DataBind method of a shapefile, it will automatically acquire extra shape fields which are populated from a database table. These extra fields can then be utilized in the same manner as shape fields which have been imported from an ESRI shapefile. In order to perform the data biding you have to provide the following information:
  • Data source - this can be a data table or a connection string (to an OleDb or a SQL Server database) and a table name.
  • Primary key column - the name of the column from the attribute table of the shape file to use as a primary key. Note that the values in this column must uniquely identify the shapes in order for the data binding to work properly.
  • Foreign key column - the name of the data table column to use for matching features with the data to import.
  • Binding column - the name of the data table column we want to import data from. A matching between the value of the primary key column and the foreign key column is done and if they match the data in the binding column of the current record is added as a new attribute to the feature.

Fill Rules

Fill rules are used to colorize a map based on the values of a shape field. When creating a fill rule you must specify the shapefile it is used on, the fill rule data column name and the colors to use (all of them or only the first, the last and their count). There are two types of fill rules:
  • Value fill rules - all unique values in the fill rule’s data column are extracted and each unique value is colorized with the respective color. If the unique values are more than the colors, then the color counting is restarted and some different values will have the same color.
  • Range fill rules - these fill rules are only applicable to data columns containing numbers. All unique values in the fill rule’s data column are extracted and then are grouped in a specified number of classes using the grouping algorithm specified to the DataGrouping property.
You can easily create and add fill rules to the FillRules collection of the map:

NMapFillRuleRange fillRule = new NMapFillRuleRange(countries, "POP_CNTRY", Color. White, Color.Black, 12);
fillRule.DataGrouping = DataGrouping.Optimal;

Following is an example of the different data grouping methods applied on a world map containing information for the population of each country:

Equal Distribution - also known as quantiles, this method allows for unequally sized data intervals and involves adjustment of the interval limits until an equal number of data points can be slotted into each interval.
Map Equal Distribution

Fig. 2

Equal Interval - also known as equal ranges (or steps), this method involves division of the entire data range into equally sized intervals.
Map Equal Interval

Fig. 3

Optimal - adjusts the size of data intervals in order to minimize the classification error and thus the map looks more balanced and the results seem more correct, with just a few shapes in the highest class as one would expect.
Map Optimal

Fig. 4

Map Simplification

Simplification of a shape is a process which involves removing of points from the shape’s outline. The algorithm tries to preserve the original contour as much as possible. To control the level of data point reduction you specify a simplification factor - the greater the factor, the greater the reduction. The algorithm interprets the simplifica¬tion factor as follows: is p and q are 2 non adjacent points from the list and all points between p and q in the list are located at a distance smaller than the simplification factor from the line segment p-q then all points between p and q are removed. For example if points is a list of points, you can simplify it using only one line of code:

NPointFList simplified = NPointFList.Simplify(points, 3);

Map before simplification:

Iceland 1

Fig. 5
Map after simplification:

Iceland 2

Fig. 6

By reducing the number of points, the electronic size of the map is reduced, and this can lead to an improvement in map display performance and the storage capacity needed for saving the map.

Main Classes Overview

All classes and interfaces referring to the mapping functionality are placed in the Nevron.Diagram.Gis namespace. Let’s take a closer look at them.

1. NEsriShapefile - represents an ESRI shapefile containing geographical data. Provide the name of the ESRI shapefile (.shp) to the constructor and then call the Read method. For each shapefile you can specify the name of the column it will use for naming the diagram elements and the min and max zooming factor it will be shown on.

2. NEsriMap - represents a collection of ESRI shapefiles. You can add one or more files using the Add method. It returns a reference to the ESRI shapefile, so that you can set one or more of its properties if you want to. The Read method is used to read all shapefiles in the map. You can use the indexer to get a reference to the shapefiles. The GetAllFeatures method returns all shapes in all shapefiles of the map. Using the Parallels and Merdians properties you can specify the way they are rendered. The Projection property determines the projection used to convert the 3D geographical data to 2D map data.

3. NGisFeature - this class is the base for all ESRI shapes. It contains two important values that are common for all ESRI shapes - the shape type (the possible shape types are described in the ENShapefileRecordType enum) and the attributes of the shaped. The attributes are read from the .dbf file that has the same name as the .shp file and are stored as a DataRow object.

4. INFeatureCreatedCallback - interface containing callbacks for shape creation. You should implement this interface if you want to be informed each time a diagram element is created and imported from the ESRI shapefile to the diagram. This makes it easy for you to apply additional styling on the imported diagram elements according to the attributes of each shape. For example if you want to make the cities that have population more than 5 000 000 two times bigger than the others you should use code similar to:

public void OnPointCreated(NDiagramElement element, NGisFeature feature)
NPointElement pe = (NPointElement)element;
float population = float.Parse(feature.Attributes["POPULATION"].ToString());
if (population > 5000000)
pe.Size = new NSizeF(2 * pe.Size.Width, 2 * pe.Size.Height);

5. NEsriImporter - this class is used to convert ESRI features to diagram elements and import them in your diagram. As said previously in the How to add a map section the class provides some properties that can help you control the importing process:
  • PolygonsAsShapes, PolylinesAsShapes - determine whether to render the objects as shapes or as paths.
  • ImportInMultipleLayers - determines whether to import the data from each ESRI file into separate layer.
  • FeatureCreatedCallback - if you want to perform additional customization on each diagram element implement the INFeatureCreatedCallback interface and set it to this property.

6. NGisProjection - abstract base class for the projections that specify how to interpret the 3D map data as 2D rendering data. Currently the following projections are available:

Aitoff Map Projection

Bonne Map Projection

Cylindrical Equal-Area Map Projection

Equirectangular Map Projection

Eckert IV Map Projection

Eckert VI Map Projection

Hammer Map Projection

Kavrayskiy VII Map Projection

Mercator Map Projection

Miller Cylindrical Map Projection

Mollweide Map Projection

Orthographic Map Projection

Robinson Map Projection

Stereographic Map Projection

Van der Grinten Map Projection

Wagner VI Map Projection

Winkel Tripel Map Projection


The growing need of applications that provide geographical aware data makes it very important for any developer to have a robust and carefully tested solution that will save his time by simplifying the process of adding geographical and mapping features to his application. And here’s where Nevron mapping solution comes in handy. More information on Map Import is available in the Users Guide shipped with the fully-functional evaluation of the Diagram for .NET.

About Nevron Software

Founded in 1998, Nevron Software is a component vendor specialized in the development of premium presentation layer solutions for .NET based technologies. Today Nevron has established itself as the trusted partner worldwide for use in .NET LOB applications, SharePoint portals and Reporting solutions. Nevron technology is used by many Fortune 500 companies, large financial institutions, global IT consultancies, academic institutions, governments and non-profits.
For more information, visit: www.nevron.com.

Customer Quotes:

QUOTE We are very pleased with our decision to use Nevron. The diagram product is excellent and the support outstanding. To successfully implement an extensible diagram based simulation platform, we needed a versatile, well structured and proven diagram platform. Nevron Diagram proved to be all of this and more. Since we selected Nevron Diagram as our diagram platform, we haven't looked back. UNQUOTE

Miek Venter, Developer
M-Tech Industrial (Pty) Ltd.