Use Cases > PTV xMap > How to Change the Language of Maps

How to Change the Language of Maps

This example shows how to change the language that is used for text ( city names, etc.) in maps. Changing the language of maps involves two steps: first you have to create a profile on your PTV xMap Server and second you have to reference the profile in your mapping request. For the first step you will require access to the PTV xServer program directory.

Localization

Creating PTV xMap Server Profiles

In this first step we create a PTV xMap Server profile by adding an additional file to the conf directory of your PTV xMap Server installation. This directory contains multiple files with default settings which shouldn't be edited without knowing the consequences.

The configuration files are named as follows: xmap-[language].properties. Tip: Select the link "View configuration files" via the PTV xServer Management Console in order to check your configuration files which should be automatically found by the PTV xMap Server.

Create a file xmap-italian.properties and add the following text. The map.profile parameter expects a ".ini"-file as default parameter. Don't be confused that the ".properties"-file is called by its own and the properties to specify the language are added below as content instead of the expected ".ini"-file.

map.profile=xmap-italian.properties

 

# INI file contents below
[config.street.generic]
language=53

You have to set the language property through the numeric value that represents the language in order to change the labels regarding the specific language which should be plotted. A set of numeric values is exemplarily displayed below:

Using a Profile

To use specific languages as shown above you have to add the profile property in the before instantiated class CallerContext.

If the configuration file is called xmap-[myProfileName].properties , the name of the profile which has to be used as value for the CallerContextProperty is myProfileName. In this example you can select three languages selected via ComboBox. Consequently the correct profile name will be added in the CallerContextProperty.

Step 1: Define the specific languages to visualise the labels.

Java snippet
private static final String[] AVAILABLE_PROFILES =
new String[]{"italian", "french", "german"};

 

Step 2: Set CallerContext and select one the three options.

Java snippet
CallerContext ctx = new CallerContext();
CallerContextProperty ctx_property = new CallerContextProperty();
ctx_property.setKey("Profile");
ctx_property.setValue(this.profileComboBox.getSelectedItem().toString());
CallerContextProperty[] properties = {ctx_property};
ctx.setProperties(properties);
		
xmapClient.setCallerContext(ctx);

Source Code

The example mapping with language is also executable as a stand-alone java program.