ActiveReports 14 .NET Edition
ActiveReports 14 User Guide / Samples and Walkthroughs / Walkthroughs / Page Report/RDL Report Walkthroughs / Map / Reports with Map
In This Topic
    Reports with Map
    In This Topic

    You can create a page report that contains a map using the ActiveReports Map control. The Map data region shows your data on a geographical background. This walkthrough illustrates how to create a report that uses a Map to display data.

    The walkthrough is split into the following activities:

    Note:
    • This walkthrough use tables from the Reels database. The Reels.mdb file can be downloaded from GitHub: ..\Samples14\Data\Reels.mdb.
    • Although this walkthrough uses Page reports, you can also implement this using RDL reports.

    When you complete this walkthrough you get a layout that looks similar to the following at design time and at run time.

    Design-Time Layout

    Map at design time

    Map at design time

    Run-Time Layout

    Map at run time

    Map at run time

    To add an ActiveReport to the Visual Studio project

    1. Create a new Visual Studio project.
    2. From the Project menu, select Add New Item.
    3. In the Add New Item dialog that appears, select ActiveReports 14 Page Report and in the Name field, rename the file to CustomersPopulation.
    4. Click the Add button to open a new fixed page report in the designer.

    See Quick Start for information on adding different report layouts.

    To connect the report to a data source

    1. In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the Add button.
      Adding a datasource
    2. In the Report Data Source Dialog that appears, select the General page and in the Name field, enter a name like ReportData.
    3. On this page, create a connection to the Reels database. See Connect to a Data Source for information on connecting to a data source.

    To add a dataset

    1. In the Report Explorer, right-click the data source node and select the Add Data Set option or select Data Set from the Add button.
    2. In the DataSet Dialog that appears, select the General page and enter the name of the dataset as Customers. This name appears as a child node to the data source icon in the Report Explorer.
    3. On the Query page of this dialog, in the Query field enter the following SQL query.
      SQL Query
      Copy Code
      SELECT Address.Region, Customer.CustomerID FROM (Address INNER JOIN Person ON Address.[AddressID] = Person.[AddressID]) INNER JOIN Customer ON Person.[PersonID] = Customer.[PersonID];
      
    4. Click the Validate DataSet icon at the top right hand corner above the Query box to validate the query.
      Validate DataSet icon
    5. Click OK to close the dialog. Your data set and queried fields appear as nodes in the Report Explorer.

    To add a Map data region and configure its data

    1. From the Visual Studio toolbox, drag and drop a Map control onto the design surface.
    2. In the Select a Map Template wizard that appears, select the USA Map template.
    3. Click the Map until the map panes appear.
    4. In the layers pane, right click PolygonLayer1 and select Layer Data to open Map Layer Data Properties dialog.
    5. In the Map Layer Data Properties dialog that appears, go to the Analytical data page.
    6. Select Customers from the Dataset property combo box and then click the Add (+) button located next to the Match label. This creates an empty match item and enables its Spatial and Analytical fields editor.
      Note: It is necessary to set match fields if you want to use a spatial data field from analytical data, or if you want to visualize analytical data on the map layer. Match fields enable the report processor to build a relationship between the analytical data and the spatial data.
    7. In the Spatial field property, select STATE_ABBR from the combo box; and similarly, select =Fields!Region.Value in the Analytical field property. This builds the match field expression and relates the analytical data to map elements on a polygon layer.
    8. Click OK to close the dialog.

    To configure appearance of the Map

    1. In the layers pane, right click PolygonLayer1 and select Edit to open Map Polygon Layer dialog.
    2. In the General page of the dialog, select #STATE_NAME from the Label Text combo box to display as label inside polygons at run time.
    3. Go to the Color Rule page of the dialog, and select Visualize data by using color palette option. This activates the tabs below.
    4. On the General tab, enter the following expression =Count([CustomerID]) in the Data field property and set Palette property to SemiTransparent.
    5. On the Distribution tab, set the Method property to EqualInterval.
    6. On the Legends tab, click to select Show in Legend.
    7. In Legend Name, enter Legend. This name relates to the default legend that appears in the Legend collection.
    8. Click OK to close the dialog.
    9. On the design surface, click on the Map control to select it and go to the Properties Window to set the following properties:

      Properties

      Property Name Property Value
      BackgroundColor White
      BackgroundGradientEndColor White
      BorderStyle Solid
      ColorScale > Hidden True
      DistanceScale > Hidden True
      Location 0in, 0.625in
      Size 6.5in, 4.75in
      ViewPort > BackgroundColor LightSteelBlue
      ViewPort > BackgroundGradientEndColor White
      ViewPort > BorderStyle None
      ViewPort > CoordinateSystem Planar
      ViewPort > Margin > Right 20pt
      ViewPort > Meridians > Hidden True
      ViewPort > Parallels > Hidden True
      ViewPort > View > Zoom 115
    10. With the Map control selected, go to the Properties window, click the Legends (Collection) property and then click the ellipsis button that appears.
    11. In the LegendDesigner Collection Editor that appears, under the Members list, select the existing legend and set the following properties:

      Properties

      Property Name Property Value
      BackgroundColor LightSteelBlue
      BackgroundGradientEndColor White
      Location > DockOutsideViewport False
      Location > DockPosition RightBottom
      Title > (Caption) Number of Customers
      Title > Font Normal, Arial, 10pt, Bold
    12. Click OK to close the dialog.
    13. With the Map control selected, go to the Properties window, click the Titles (Collection) property and then click the ellipsis button that appears.
    14. In the MapTitleDesigner Collection Editor that appears, with Title selected in the Members list set the following properties:

      Properties

      Property Name Property Value
      (Text) Customers Population
      Color Black
    15. Click OK to close the dialog.

    To view the report

    • Click the preview tab to view the report at design time.

    OR