Example of using geographic map

This document takes OpenStreetMap for example to describe how to add a geographic map in a library component and use it in JDashboard.

Creating a library component with a geographic map
  1. Open the catalog file SampleReports.cat in the SampleReports folder.
  2. Click File > New > Library Component on the menu bar.
  3. In New Library Component dialog, clear the text in the Library Component Title box, select Blank, and then click OK.
  4. Drag Geographic Map from the Toolbox panel to the library component. The Create Geographic Map wizard appears.
  5. In the Data screen of the wizard, select WorldWideSalesBV from Data Source 1. Then click Next.
  6. In the Display screen, add the fields Country and State in the Customers table as the group by fields one by one to the Drill Path box.
  7. Check the Enable Area checkbox. The Enable Marker checkbox is checked by default.

    Next, we will define the marker and area properties for the country group level.

  8. Click Country in the Drill Path box, select Country from the Customers table in the Resources box and click to add it to the Shape By text box, then click beside the text box.
  9. In the Edit Shapes dialog, click anywhere in the Data Items box and click Ctrl + A on the keyboard to select all countries, then click in the preview box below the pattern name to apply the shape to all countries. Click OK to apply the shape.

  10. Select the aggregation Total Sales from the Orders Detail table in the Resources box and click to add it to the Color By text box, then click beside the text box.
  11. In the Edit Gradient Color dialog, keep the default gradient color, check the Middle Value checkbox and set its value to 625816.73, specify the opacity to 80%, then click OK to apply the gradient color.

  12. Select the aggregation Total Cost from the Orders Detail table in the Resources box and click to add it to the Size By text box, then click beside the text box to specify the zoom percentage to 370%. Click outside of the size box to apply the zoom percentage.
  13. Select Country from the Customers table in the Resources box and click to add it to the Label By text box of the Marker Options.
  14. Click beside the Marker Tip text field, then select <Create Formula> from its drop-down list to create a formula to control the marker tip information.
  15. In the Input Formula Name dialog, enter the name MarkerTipforCountry and click OK.
  16. In the Formula Editor window, define the formula as follows.

    "Country:" + " " + @"Customers.Country" + "\n" +
    "Total Cost:" + " " + ToText(@"Orders Detail.Total Cost","$#,###.00") + "\n" +
    "Total Sales:" + " " + ToText(@"Orders Detail.Total Sales","$#,###.00")

  17. Save the formula and close the Formula Editor. MarkerTipforCountry will be displayed in the Marker Tip text field.

  18. Select the aggregation Total Sales from the Orders Detail table in the Resources box and click to add it to the Fill By text box, then click beside the text box.
  19. In the Edit Gradient Color dialog, select Green-White-Orange from the gradient color drop-down list, which is the last color at the second line in the list, specify the opacity to 80%, then click OK to apply the gradient color.

    Next, we will specify the marker and area properties for the state group level.

  20. Click State in the Drill Path box, select State from the Customers table in the Resources box and click to add it to the Shape By text box, then click beside the text box.
  21. In the Edit Shapes dialog, select Pattern1 from the pattern drop-down list to apply the shapes in the pattern to all states, then click OK.
  22. Click beside the Size By text box to specify the zoom percentage to 230%. Click outside of the size box to apply the zoom percentage.
  23. Select the aggregation Total Sales from the Orders Detail table in the Resources box and click to add it to the Fill By text box, then click beside the text box.
  24. In the Edit Gradient Color dialog, select Green as the gradient color, which is the second color in the color list, specify the opacity to 80%, then click OK to apply the gradient color.
  25. Select State from the Customers table in the Resources box and click to add it to the Label By text box of the Area Options. Repeat this to add Total Sales from the Orders Detail table to the Label By text box.
  26. Repeat steps 14 to 17 to create another formula AreaTipforState to control the area tip information.

    "Country:" + " " + @"Customers.Country" + "\n" +
    "State:" + " " + @"Customers.State" + "\n" +
    "Total Sales:" + " " + ToText(@"Orders Detail.Total Sales","$#,###.00")

  27. Repeat steps 14 to 17 to create another formula LocationInfoforState for the Location Info option.

    @"Customers.State" + "," + @"Customers.Country"

  28. Click Next to enter the Filter screen. Click the Add Condition button to add a condition line, and specify the filter condition as @Country != USA , then click Finish to create the map.

  29. Select GeoMarker1 and GeoArea1 in the Report Inspector by pressing the Ctrl key on the keyboard and set their Invisible property to true. This is to hide information about the state group level from displaying at the initial map to improve the map appearance. You can still get the state information by applying the go-down action on the countries.
  30. Click File > Save to save the library component as Sales Map by Country.lc.
Displaying the geographic map in JDashboard
  1. Publish the library component to the default location on JReport Server together with the resources used by it.
  2. Start JReport Server and access the JReport Console page.
  3. On the JReport Console > Resources page, click New > Dashboard. A blank dashboard will be created.
  4. Click  on the side bar to display the Resources panel.
  5. Browse to find the library component Sales Map by Country.lc in the Component Library node and then drag it to the dashboard body. You can see the formats we defined in the Display screen of the Create Geographic Map wizard are applied to the markers and areas, and when you hover the mouse on a marker, its tip information will also be displayed just as we defined.

  6. In this geographic map component, there are two group levels, first by Country and then by State. For the higher group level, you can perform the go-down action, and for the lower group level, the go-up action. Hover your mouse over the marker Country: Germany, click it, or right-click it and select Go Down from the shortcut menu. The geographic map will jump one group level down to show the information of states in Germany.

  7. You can scroll the mouse over the geographic map to make it zoom out or zoom in. By scrolling the mouse down, a wider area will be shown on the map.