Maps in QueryViewer

Official Content
This documentation is valid for:

In some situations, it is necessary to represent geographic locations such as countries, cities, etc.

As from GeneXus 17 upgrade 4, this data can be represented on maps in the QueryViewer control.

For example, look at the image below. It represents the total number of SARS-CoV-2 (Covid-19) cases per million people in each country.

image_2021610162042_1_png

In this case, a Choropleth type map is used.

Now, look at this other map below. It represents the total number of deaths per million in each country.

image_2021610162130_1_png

In this case, the data is represented in a Bubble type map. 

How is it done with GeneXus?

For a query to be displayed on a map, you need to define in the Query object an attribute containing the ISO 3166-1 or ISO 3166-2 codes, depending on the geographic entities to be represented. For this attribute, its Type property must be set to Axis.

image_202161017326_1_png

In addition, it is necessary to add another attribute with the numerical data related to the geographic entity. In this case, it is CountryCasesPerMillion. The Type property of the Query element must be set to Datum.

image_20216101885_1_png

Additionally, you can choose the color of the data represented on the map. You can do this by setting the ForeColor property of the attribute whose type is Datum. Note that if no color is selected, a default color will be assigned.

Take a look at the following example. To represent specific colors for the different data values on the map, you can configure them in the Conditional styles property.

image_2021614163626_1_png

In this case, the Conditional styles property is configured as follows:

image_202161416554_1_png

image_2021614165258_1_png

You can define this type of output using the QueryViewer control. To this end, the QueryViewer control (inserted in a web form) must have the Type property set to Map.

image_2021610165635_1_png

In the Map Type property, select the map you want to use (Choropleth or Bubble).

image_2021611135756_1_png

In the Region property, set the type of map in which you want to represent the data (World, Continent, or Country).

image_20216111420_1_png

Note that if you select the Country property or Continent property, the maps available for each option will be displayed.

The map type can also be configured programmatically through the enumerated domains QueryViewerMapType, QueryViewerCountry, QueryViewerRegion, and QueryViewerContinent.

Take a look at the following example. To represent the total vaccinated population per department per country, with a combo box to select the country and the type of map, you need to set it as follows:

image_202161514264_1_png

In this case, the enumerated domains used were QueryViewerRegion (to set the Region property to Country), QueryViewerCountry (to set the Country property to an initial value), and QueryViewerMapType (to change the MapType setting in Choropleth and Bubble).

image_20216151596_1_png
Look at the following image. Changing the combo box options to another country and another type of map:

image_2021615163244_1_png

Considerations

1. The library used is ECharts.

2. GeneXus provides the following country maps:

  •  Afghanistan 
  •  Albania 
  •  Algeria 
  •  Andorra 
  •  Angola 
  •  Anguilla 
  •  Antigua and Barbuda 
  •  Argentina 
  •  Armenia 
  •  Australia 
  •  Austria 
  •  Azerbaijan 
  •  Bahrain 
  •  Bangladesh 
  •  Barbados 
  •  Belarus 
  •  Belgium 
  •  Belize 
  •  Benin 
  •  Bermuda 
  •  Bhutan 
  •  Bolivia 
  •  Bosnia and Herzegovina 
  •  Botswana 
  •  Brazil 
  •  British Virgin Islands 
  •  Brunei 
  •  Bulgaria 
  •  Burkina Faso 
  •  Burundi 
  •  Cambodia 
  •  Cameroon 
  •  Canada 
  •  Cape Verde 
  •  Central African Republic 
  •  Chad 
  •  Chile 
  •  China 
  •  Colombia 
  •  Comoros 
  •  Cook Islands 
  •  Costa Rica 
  •  Croatia 
  •  Cuba 
  •  Cyprus 
  •  Czech Republic 
  •  Democratic Republic of the Congo 
  •  Denmark 
  •  Djibouti 
  •  Dominica 
  •  Dominican Republic 
  •  East Timor 
  •  Ecuador 
  •  Egypt 
  •  El Salvador 
  •  Equatorial Guinea 
  •  Eritrea 
  •  Estonia 
  •  Eswatini 
  •  Ethiopia 
  •  Faroe Islands 
  •  Fiji 
  •  Finland 
  •  France 
  •  Gabon 
  •  Gambia 
  •  Georgia 
  •  Germany 
  •  Ghana 
  •  Greece 
  •  Greenland 
  •  Grenada 
  •  Guatemala 
  •  Guinea 
  •  Guinea Bissau 
  •  Guyana 
  •  Haiti 
  •  Honduras 
  •  Hungary 
  •  Iceland 
  •  India 
  •  Indonesia 
  •  Iran 
  •  Iraq 
  •  Ireland 
  •  Israel 
  •  Italy 
  •  Ivory Coast 
  •  Jamaica 
  •  Japan 
  •  Jordan 
  •  Kazakhstan 
  •  Kenya 
  •  Kiribati 
  •  Kosovo 
  •  Kuwait 
  •  Kyrgyzstan 
  •  Laos 
  •  Latvia 
  •  Lebanon 
  •  Lesotho 
  •  Liberia 
  •  Libya 
  •  Liechtenstein 
  •  Lithuania 
  •  Luxembourg 
  •  Madagascar 
  •  Malawi 
  •  Malaysia 
  •  Maldives 
  •  Mali 
  •  Malta 
  •  Marshall Islands 
  •  Mauritania 
  •  Mauritius 
  •  Mexico 
  •  Micronesia 
  •  Moldova 
  •  Monaco 
  •  Mongolia 
  •  Montenegro 
  •  Morocco 
  •  Mozambique 
  •  Myanmar 
  •  Namibia 
  •  Nauru 
  •  Nepal 
  •  Netherlands 
  •  New Zealand 
  •  Nicaragua 
  •  Niger 
  •  Nigeria 
  •  North Korea 
  •  North Macedonia 
  •  Norway 
  •  Oman 
  •  Pakistan 
  •  Palau 
  •  Panama 
  •  Palestine 
  •  Papua New Guinea 
  •  Paraguay 
  •  Peru 
  •  Philippines 
  •  Poland 
  •  Portugal 
  •  Puerto Rico 
  •  Qatar 
  •  Republic of the Congo 
  •  Romania 
  •  Russia 
  •  Rwanda 
  •  Saint Kitts and Nevis 
  •  Saint Lucia 
  •  Saint Vincent and the Grenadines 
  •  Samoa 
  •  San Marino 
  •  Sao Tome and Principe 
  •  Saudi Arabia 
  •  Senegal 
  •  Serbia 
  •  Seychelles 
  •  Sierra Leone 
  •  Singapore 
  •  Slovakia 
  •  Slovenia 
  •  Solomon Islands 
  •  Somalia 
  •  South Africa 
  •  South Korea 
  •  South Sudan 
  •  Spain 
  •  Sri Lanka 
  •  Sudan 
  •  Suriname 
  •  Sweden 
  •  Switzerland 
  •  Syria 
  •  Taiwan 
  •  Tajikistan 
  •  Tanzania 
  •  Thailand 
  •  The Bahamas 
  •  Togo 
  •  Tokelau 
  •  Tonga 
  •  Trinidad and Tobago 
  •  Tunisia 
  •  Turkey 
  •  Turkmenistan 
  •  Tuvalu 
  •  Uganda 
  •  Ukraine 
  •  United Arab Emirates 
  •  United Kingdom 
  •  United States of America 
  •  Uruguay 
  •  Uzbekistan 
  •  Vanuatu 
  •  Vatican City 
  •  Venezuela 
  •  Vietnam 
  •  Western Sahara 
  •  Yemen 
  •  Zambia 
  •  Zimbabwe 

3. The following continent maps are available:

  • Africa
  • Antarctica
  • Asia
  • Europe
  • North America
  • Oceania
  • South America.

In addition, the World map is offered.

4. Please note that regardless of the list of countries provided by GeneXus, only the following maps are supported with their ISO 3166-2 codes including their main territorial divisions:

  • Argentina
  • Brazil
  • Chile
  • China
  • Japan
  • Mexico
  • Paraguay
  • Spain
  • United States of America 
  • Uruguay

This means that if you want to use a map that is not listed above, you must add the ISO 3166-2 codes in the relevant subdivisions of the map you want to use. 

To do so, look for the js file of the required map; the country maps can be found in the following directory: UserControls/QueryViewer/Echarts/countries. Next, look for the map by its corresponding ISO 3166-1 code; i.e. if you want to add the ISO 3166-2 codes of France, go to the following directory: UserControls/QueryViewer/Echarts/countries/fr-all.js.

In the fr-all.js file, inside the properties of each subdivision, add the "iso-code" property, as shown in the following example:

image_2021611155929_1_png

Note that you will only have to do this if the map of the country you want to represent is not included in the list supported by GeneXus. On the other hand, the continent maps and the World map include all the countries with their corresponding ISO 3166-1 codes.

Availability

This feature is available since GeneXus 17 upgrade 4.