New in 2012 v1, the C1ReportDesigner application has support for mapping. By adding visual maps to your reports you can do things like:
With the banded report model, you can easily render maps on multiple pages of the report (in each group or record), or just show a single map at the beginning or end of the report. The custom Map field is implemented using the C1.WPF.Maps assembly, and you can generate reports for any client (ie view the reports in Silverlight, ASP.NET, WPF, WinForms, etc).
Now let’s walk through creating a simple report that shows customers by country using this new map field. First, let’s create the base report. Open up the C1ReportDesigner application and create a new report using the wizard. For this example I will use the classic Northwind database. Step 1: Create a new connection the Nwind.mdb file (you can find a copy under ComponentOne Samples/Common), and select the Customers table for the report. Step 2: Select some fields for the Detail section of the report, and some for the Group. This report will be grouped by Country, although it is not necessary for the map. Step 3: Select the outline layout for the new report. Step 4: Select the style for the new report, such as Aspect. Step 5: Name the report "Customers Report" and click finish. The report is now ready to add mapping. Add a Map field to the Header section of the report. You can customize various features of the map control such as tile and data layers, legends, styles, expressions, and zoom level. For this sample I want to see the whole world, but not those white spaces. Select the Map field and set these properties:
Next, open the Layers collection and add a PointsLayer. This layer will be used to display a marker for every customer. Set these properties in the LayerBase Collection Editor:
The key to plotting markers on a map is knowing the longitude and latitude data. Points and lines layers provide two different ways to specify the spatial locations for the data:
Whatever fields you specify in Latitude, Longitude or MapLocation must be part of the RecordSource query. Click OK and preview the report. Note that using MapLocation may be very time consuming due to Internet access. Hence by default the retrieved spatial data is stored in a local disk file. The path to that file is specified by the GeoCachePath property. By default the file's name is "geocache.xml", and it is stored in the same directory as the report definition. Disabling geocaching is not recommended.
The points layers collection supports clustering. When several point markers are located close to one another they may be "clustered" together into a single marker. Simply specify the cluster distance and the cluster styles in the layer collection editor.
Click OK and preview the report.
This sample just has one layer, but it’s quite possible to have many layers. Each layer may represent a different entity such as Suppliers, Employees, etc. You can add a Legend to the map by simply adding one to the Legends collection. By setting the legend’s Automatic property to True it will generate from the layers collection. Note: the text color of the legend items is determined by the text color specified for each layer. Add another PointsLayer with the RecordSource set to "SELECT * FROM SUPPLIERS" and set it up exactly like Customers but with a different style. Now we can show multiple layers and a legend.
For optimal disk space of your exported reports, you can lower the TargetDpi value. The map is rendered as an image in the final document. The TargetDpi controls the resolution of the image so the higher the resolution the larger the image file. The default value is 200. A good, bare minimum dpi is 72 if you are concerned about file size.
Adding maps can be an interesting way to view geographic data. The Map field also has support for drawing lines between two spatial locations, as well as loading KML files as the source. Below is a collection of sample reports that use more of the features than the sample described above. Download Sample Download Studio for WinForms