Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

(Difference between revisions)

Setting the Map language in the Maps API for Java ME

From Wiki
Jump to: navigation, search
trashedDev (Talk | contribs)
(TrashedDev -)
trashedDev (Talk | contribs)
(TrashedDev -)
Line 5: Line 5:
|installfile= [[ | Map Language MIDlet Binaries]]<!--  Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|installfile= [[ | Map Language MIDlet Binaries]]<!--  Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices=X3-02, Asha 305
|devices=X3-02, Asha 305
|sdk=[[ Nokia SDK 1.0 for Java] [ Nokia SDK 2.0 for Java (beta)]]
|sdk=[ Nokia SDK 1.0 for Java] [ Nokia SDK 2.0 for Java (beta)]
|dependencies=  [ Maps API for Java ME] v1.0
|dependencies=  [ Maps API for Java ME] v1.0
|platform=S40, Symbian^1, Symbian^3
|platform=S40, Symbian^1, Symbian^3

Revision as of 08:01, 28 June 2012

This article explains how to alter the map language of a Java ME application

Article Metadata
Code ExampleTested with
Devices(s): X3-02, Asha 305
Device(s): All
Dependencies: Maps API for Java ME v1.0
Keywords: Location API, Nokia Maps, MapDisplay, Application Context, Language
Created: jasfox (23 Mar 2012)
Last edited: trashedDev (28 Jun 2012)


By default all the maps in the Map API for Java ME will display in English. The API is able to support a variety of other languages however. The language used to display labels on the map is set in the ApplicationContext, and this should be done prior to displaying the map itself. The setDefaultLanguage() method takes a three letter MARC Code. If an unsupported language is requested, the map will display in English by default.

Examples of usable MARC codes include:

  • ARA Arabic
  • CHI Chinese
  • GER German
  • ENG English
  • FRE French
  • ITA Italian
  • RUS Russian
  • SPA Spanish


This is a simple example of a minimal map which will display in one of eight random languages.

public class MapLanguageMIDlet extends MIDlet {
protected void startApp() throws MIDletStateChangeException {
// Please initialise the appId and token first
ApplicationContext ctx = ApplicationContext.getInstance();
Display display = Display.getDisplay(this);
MapLanguageDemo minimalMap = new MapLanguageDemo(display, this);
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {}
protected void pauseApp() {}

public class MapLanguageDemo extends MapCanvas implements CommandListener {
private final Command EXIT = new Command("Exit", Command.EXIT, 1);
private final static String[] MARC_CODES = {"ARA", "CHI", "GER", "ENG",
"FRE", "ITA", "RUS", "SPA"
private final static String[] LANGUAGES = {"Arabic", "Chinese", "German", "English",
"French", "Italian", "Russian", "Spanish"
protected MIDlet midlet;
public MapLanguageDemo(Display display, MIDlet midlet) {
this.midlet = midlet;
private void init() {
Random r = new Random();
int i = r.nextInt(LANGUAGES.length);
// Set map over Europe.
new MapDisplayState(new GeoCoordinate(53.1, 13.1, 0), 4));
public void commandAction(final Command c, Displayable d) {
if (c == EXIT) {
public void onMapUpdateError(String description, Throwable detail, boolean critical) {
Alert alertView = new Alert("Map error: ", detail.getMessage(), null, AlertType.ERROR);
public void onMapContentComplete() {

Example Output

Chinese Russian Arabic
Chinese.png Russian.png Arabic.png
92 page views in the last 30 days.