Diagram / Maps / Customization
In This Topic
    Customization
    In This Topic

    NOV map importer lets you customize the appearance of the imported map shapes by using fill rules as explained in the Fill Rules topic. The map importer also lets you configure the look of the map arcs, i.e. parallels and meridians through the ParallelSettings and MeridianSettings properties respectively.

    When fill rules are not enough and you want to customize the appearance or the behaviour of the imported shapes even further, you can take advantage of the ShapeCreatedListener property of the map shape importer. It accepts an implementation of the INShapeCreatedListener interface, which contains methods, called by the shape importer when a shape of a specific type is created (e.g. a polygon shape, a polyline shape, etc.). You can use these callback methods to further customize the created shape or to even cancel it's import to the drawing document by returning false.

    For convenience, when you want to customize only some types of shape, instead of implementing the INShapeCreatedListener, you can extend the NShapeCreatedListener class, which simply is an empty implementation of the interface. The following code example demonstrates how to create a custom shape created listener, which adds a tooltip to each created shape:

    Creating a custom shape created listener
    Copy Code
    public class NCustomShapeCreatedListener : NShapeCreatedListener
    {
        public override bool OnMultiPolygonCreated(NShape shape, NGisFeature feature)
        {
            return OnPolygonCreated(shape, feature);
        }
    
        public override bool OnPolygonCreated(NShape shape, NGisFeature feature)
        {
            INDataTableRow row = feature.Attributes;
            string countryName = (string)row["name_long"];
            decimal population = (decimal)row["pop_est"];
    
            string tooltip = countryName + "'s population: " + population.ToString("N0");  
            shape.Tooltip = new NTooltip(tooltip);
    
            return true;
        }
    }
    

    As you see in the sample source code, every callback method of the shape created listener has two parameters - the created shape and the geographical data (called GIS feature) from which the shape was created. You can use the Attributes property of the GIS feature to get the value of the attribute you are intersted in for the created shape.

    When you have created your custom shape created listener, do not forget to assign it to the ShapeCreatedListener property of the shape importer:

    Assigning the shape created listener
    Copy Code
    mapImporter.ShapeCreatedListener = new NCustomShapeCreatedListener();
    mapImporter.Read();
    mapImporter.Import(m_DrawingDocument, page.Bounds);
    
    See Also