Nevron .NET Vision
Diagram for .NET / User's Guide / Maps / Map Importer

In This Topic
    Map Importer
    In This Topic

    The NMapImporter class contains properties and methods that let you configure the appearance of the imported map:

     Properties
    • Parallels, Meridians - you can use these properties to configure the way the map arcs are rendered. For each collection of arcs you can set the way they are rendered (below or above the other map objects), whether to label them or not and the density of the arcs (None, Fine, Normal, Coarse or Fixed). For more information check out the Map Arcs topic.
    • Projection - lets 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 Map Projections topic.
    • Fill Rules - each map layer can have a fill rule. 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 topic.
    • MapBounds - defines the bounds of the map. If not set, the map bounds will be determines by the currently set map zoom. Setting the value of the MapBounds property is useful when you want to import several map layers, for example a map of the world and the map of the US with all the states and you want them to match, i.e. the US states to position correctly within the bounds of the USA map feature from the world map. In this case you should set the map bounds to NMapBounds.World. If you set only some of the map bounds (e.g. MinLatitude and MinLongitude), then the rest of the bounds will be calculated by using the map zoom object.
    • MapZoom - lets you zoom a map to a specific layer or to one or more shapes that match a given filter. By default set to "zoom to all layers", which means that the map bounds will be calculated as a union of the bounds of all map layers added to the map importer. For more information check out the Map Zoom topic.
     Customization

    You can assign an implementation of the INShapeCreatedListener interface to the ShapeCreatedListener property of the map importer in order to get notified when a diagram element is created from a map feature and imported in the drawing document. You can then directly modify the created diagram element to your liking. For your convenience you can also inherit from the NShapeCreatedListener class, which is an empty implementation of the INShapeCreatedListener interface. The following code example demonstrates how to add a tooltip to each of the created polygon shapes:

    Custom shape created listener
    Copy Code
    private class CustomShapeCreatedListener : NShapeCreatedListener
    {
        public override bool OnPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
        {
            NShape shape = element as NShape;
            if (shape == null)
                return true;
    
            string name = mapFeature.GetAttributeValue("CNTRY_NAME").ToString();
            int population = Int32.Parse(mapFeature.GetAttributeValue("POP_CNTRY").ToString());
    
            NInteractivityStyle interactivityStyle = new NInteractivityStyle(String.Format("{0} population: {1:N0}", name, population));
            NStyle.SetInteractivityStyle(shape, interactivityStyle);
    
            return true;
        }
    
        public override bool OnMultiPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
        {
            return OnPolygonCreated(element, mapFeature);
        }
     }
    

    You can then create an instance of this class and assign it to the ShapeCreatedListener of the map importer:

    Attach to map importer
    Copy Code
    mapImoprter.ShapeCreatedListener = new CustomShapeCreatedListener();