FlexReport for WinForms | ComponentOne
Fields and Custom Fields / Map Custom Field
In This Topic
    Map Custom Field
    In This Topic

    FlexReport supports map fields using its extensible custom field architecture. In the following sections, you'll see how you to customize map fields in reports using the FlexReportDesigner application. The Map custom field uses three assemblies, C1.Win.FlexReport.CustomFields, C1.Win and C1.Win.Map, which should be in the same folder as the FlexReportDesigner app.

    To start using the Map custom field in the FlexReportDesigner application, complete the following steps:

    1. Run the C1FlexReportDesigner application.
    2. Confirm that the map icon is present in the C1FlexReportDesigner toolbar. If it is not included, you may need to add the following line to the <customfields> section of the C1FlexReportDesigner.4.5.2.exe.settings/C1FlexReportDesigner.4.8.exe.settings/C1FlexReportDesigner.6.exe.settings file:
      • For Framework 6 version
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.6;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        
      • For Framework 4.8 version
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.4.8;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        
      • For Framework 4.5.2 version
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.4.5.2;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        

      You can find the C1FlexReportDesigner.4.5.2.exe.settings, C1FlexReportDesigner.4.8.exe.settings and C1FlexReportDesigner.6.exe.settings files at the following location:
      C:\Users\user_name\AppData\Roaming\C1Report\

      Note: The C1FlexReportDesigner.x.x.exe.settings file gets generated at the mentioned location only when the user first opens a report in the C1FlexReportDesigner and not at the time of installation of WinForms Edition.
    3. Create a new report or open an existing report. Refer the Quick Start for an example.
    4. Click the map icon and drag it onto your report to add a Map field.

    That's it! Now, you have successfully added a map field to your report.

    Note that if C1FlexReport definition contains map field and the report is generated asynchronously, the map field cannot be displayed in the FlexViewer control. As a workaround please set the C1FlexViewer.UseAsyncRendering property to False.

    Map Custom Field Properties

    FlexReportDesigner allows you to set important properties of the Map custom field. The Properties tab on the left-hand side displays properties for custom map field, such as Layers, Tracking, Styles, Spatial Locations and Legends.

    Layers

    The main part of a map is the tile layer which provides raster graphics representing the Earth surface or part of it, and zero or more layers representing spatial data.

    The tile layer is specified by the TileSource property. It may be set to a VirtualEarth tile source (road, aerial, or hybrid). The tile source may be set to "none" in which case no tiles will be drawn on the map. This may be useful especially when other layers such as KML provide enough data for the map visualization.

    Note that unless the tile source is "none", the tiles are loaded from a network location when the report runs, which may slow things down considerably.

    Except for the tile layer, all other layers are contained in the Layers collection. Currently, three layer types are supported as described below:

    Tracking

    The map shown by a Map field can automatically center and zoom in on the data shown on the map. This behavior is determined by two factors:

    Styles

    Visual attributes of map elements are mostly defined by styles. There are several types of styles (point marker styles, line styles and KML item styles); the applicable type is determined by the context, such as points layers use point marker styles, lines layers use line styles, and so on. Usually a style may be specified as a data driven expression (so that the actual style depends on run time data), with a fallback style used by default. How style expressions are specified and evaluated is described next.

    The Map custom field contains 3 style collections:

    These styles are available to all layers defined on the Map, and also to other Map fields in the current report. The styles in each collection are addressable either by index or - preferably - by name (using the Name property). When a style expression evaluates to a string, that string is used to search for a matching style, first in the current map and if that fails, in all other maps on the current report (only matching type styles are searched; for example, only MarkerStyles collections are searched for a point marker style, and so on).

    Spatial Locations

    Points and lines layers provide two different ways to specify spatial locations for the data:

    Legends

    A map can have several associated legends, rendered within its bounds. To facilitate placing a legend outside the map's bounds, the legend can be associated with any map field in the report, so you can add an empty map field just to hold a legend describing another map.

    Legends are contained within the Legends collection of the Map field. To add a legend, add an item to that collection. The location of a legend within its map's bounds is determined by the LegendAlignment property. Orientation determines whether items within the legend are placed vertically (default) or horizontally. Several other properties allow to fine-tune the way the legend looks.

    Items within the legend are represented by the Items collection. That collection may be populated automatically with data from non-KML layers of the current map, if the Automatic property of the legend is set to True. In that case the Items collection cannot be edited. Otherwise, the legend items must be added manually.

    The following types of legend items are supported:

    Adding Map Fields

    Now that you familiar with the basics of the custom map field, let us see how to add a map field to a report depicting the summary of Employees, Suppliers, and Customers by City.

    Complete the following steps:

    1. Create the base report.

      Add a new report in the designer, with C1NWind.mdb as the data source, with the following SQL query:
      Customers and Suppliers by City

    2. Add the main map.

      You'll add the map to the report's header:

      • Make some room for the map by dragging the header's bottom edge down in the report designer.
      • Click on the Map custom field icon and drag it onto the header.
           
    3. Adjust the map's properties.

      Set the map's properties as follows (only non-defaults are shown here):

      • AutoCenter: False
      • AutoZoom: False
      • CenterLatitude: 10
      • CenterLongitude: 15
      • ShowScale: True
      • TileSource: VirtualEarthAerial
      • ZoomLevel: .55
           
    4. Add Layers.

      Click ellipsis button next to Layers collection to open LayerBase Collection Editor. Add Members 'Employees', Suppliers', and 'Customers', select the data source and set their marker style and map location properties.
      LayerBase Collection Editor

      Note that you need to add a data source every time before you add a member to the LayerBase Collection Editor as each member uses different data source.

      The design area looks like the following image:

      Design view

    5. Preview the report.

      Preview Maps in Designer