IntroductionNowadays 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
Fig. 1
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:
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:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AppearanceThe NMap class provides properties and methods that can help you adjust the appearance of any imported map. Let's take a look at them:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data BindingThe 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:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Fill RulesFill 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:
NMapFillRuleRange fillRule = new NMapFillRuleRange(countries, "POP_CNTRY", Color. White, Color.Black, 12); fillRule.DataGrouping = DataGrouping.Optimal; map.FillRules.Add(fillRule); Following is an example of the different data grouping methods applied on a world map containing information for the population of each country:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Map SimplificationSimplification 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:
Fig. 5
Map after simplification:
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 OverviewAll 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:
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:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ConclusionThe 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 SoftwareFounded 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. |
We use cookies to allow us to automate the access and the data entry functions of our website and to correlate online ordering information for purchases you may make while at the website (if any), tailor our website to your preferences or interests, or customize promotions or marketing. For full details read our cookie policy.