Example of Using Geographic Map
This topic uses OpenStreetMap to demonstrate how to add a geographic map in a library component and use it in JDashboard.
- Open the catalog file SampleReports.cat in
<install_root>\Demo\Reports\SampleReports
. - Select Home > New > Library Component.
- In the Select Component for Library Component dialog, select Blank and select OK.
- Drag the Geographic Map button from the Components panel to the library component. The Create Geographic Map wizard appears.
- In the Data screen, select WorldWideSalesBV from Data Source 1. Then select Next.
- 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.
- 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.
- Select Country in the Drill Path box, select Country from the Customers table in the Resources box and select to add it to the Shape By text box, then select beside the text box.
- In the Edit Shapes dialog, select anywhere in the Data Items box and select Ctrl + A on the keyboard to select all countries, then select in the preview box below the pattern name to apply the shape to all countries. Select OK to apply the shape.
- Select the aggregation Total Sales from the Orders Detail table in the Resources box and select to add it to the Color By text box, then select beside the text box.
- 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 select OK to apply the gradient color.
- Select the aggregation Total Cost from the Orders Detail table in the Resources box and select to add it to the Size By text box, then select beside the text box to specify the zoom percentage to 370%. Select outside of the size box to apply the zoom percentage.
- Select Country from the Customers table in the Resources box and select to add it to the Label By text box of the Marker Options.
- Select beside the Marker Tip text field, then select <New Formula...> from its drop-down list to create a formula to control the marker tip information.
- In the displayed dialog, enter the name MarkerTipforCountry and select OK.
- In the Formula Editor, 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") - Save the formula and close the Formula Editor. MarkerTipforCountry is then displayed in the Marker Tip text field.
- Select the aggregation Total Sales from the Orders Detail table in the Resources box and select to add it to the Fill By text box, then select beside the text box.
- 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 select OK to apply the gradient color.
Next, we will specify the marker and area properties for the state group level.
- Select State in the Drill Path box, select State from the Customers table in the Resources box and select to add it to the Shape By text box, then select beside the text box.
- In the Edit Shapes dialog, select Pattern1 from the pattern drop-down list to apply the shapes in the pattern to all states, then select OK.
- Select beside the Size By text box to specify the zoom percentage to 230%. Select outside of the size box to apply the zoom percentage.
- Select the aggregation Total Sales from the Orders Detail table in the Resources box and select to add it to the Fill By text box, then select beside the text box.
- 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 select OK to apply the gradient color.
- Select State from the Customers table in the Resources box and select 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.
- 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") - Repeat steps 14 to 17 to create another formula LocationInfoforState for the Location Info option.
@"Customers.State" + "," + @"Customers.Country"
- Select Next to enter the Filter screen. Select the Add Condition button to add a condition line, and specify the filter condition as @Country != USA, then select Finish to create the map.
- 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.
- Select Hone/File > Save to save the library component as Sales Map by Country.lc.
- Publish the library componentto the default location on Logi JReport Server together with the resources used by it.
- Create a dashboard on Logi JReport Server.
- Select on the side bar to display the Resources panel.
- 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.
- 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, select 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.
- 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.