Maps API for Java ME- Getting Started

The target devices for the Maps API for Java ME are those supporting the Mobile Information Device Profile (MIDP) 2.0 or later for Java Micro Edition. This page described how to set up your development environment correctly, so you can start creating applications using the Maps API for Java ME.

Note: The development set up process described below has been optimised for the NetBeans and Eclipse IDEs, although any IDE for Java development may be used.

If you are new to Java development or development for Series 40 phones, check out the Java getting started section. In this section you can find detailed guides to setting up and using the NetBeans and Eclipse IDEs with the Nokia SDK 1.1 for Java.

Prerequisites

1. Ensure that your IDE is present on your development machine.

2. To emulate a Series 40 phone, download the latest Nokia SDK for Java . The installation will automatically integrate support with NetBeans or Eclipse if they are present on your machine. Note that the Nokia SDK 1.10 for JavaSDK requires use of JDK 6 Update 27 or earlier.

Download

3. At this point you can download the binary JAR of the Maps API for Java ME

Download

4. Acquire a set of API Credentials from the API Registration page at Nokia Developer and register your application for free. Please read the Location API Business Models and Usage Restrictions page, so that you can decide which business model fits your needs best.

For general guidance and an introduction to Java ME development, check out the Nokia Developer Guide.

Configuring the IDE

In order to run the API successfully:

  • Ensure that the configuration for the device is CLDC-1.1 and MIDP-2.0.
  • Include (as an optional package) the location based APIs.

When setting up your emulator:

  • Disable user security prompts to avoid being repeatedly asked for permission to use the network.
  • Setup both the emulator and test devices to access the internet and to authenticate/download maps successfully.

Displaying Maps on Screen

Acquiring API credentials

Maps API for Java ME invokes an authentication service when accessing maps online. Although it is possible to obtain access without acquiring authentication credentials, such access may be restricted or of inferior performance. In order to get the full potential out of the API, you must get credentials that authenticate your application against the Services. Please read through the Location API Business Models and Usage Restrictions page, so that you can decide which business model fits your needs best. The authentication itself requires your unique Maps API credentials, namely AppId and Token. You can get these credentials from the API Registration page at Nokia Developer.

Using API credentials

After registering your application, you must set the following credentials in the ApplicationContext class:

ApplicationContext.getInstance().setAppID(...);
ApplicationContext.getInstance().setToken(...);

Basic Map

The following code , when added to a MIDlet, displays a basic map of the world. The map centers on the Gulf of Guinea at 0° longitude, 0° latitude. You can pan/zoom the map by default.

Display display = Display.getDisplay(this);
MapCanvas mapCanvas = new MapCanvas(display);
display.setCurrent(mapCanvas);

Drawing objects on the Map

The Maps for Java ME API can draw a variety of shapes such as circles, rectangles and polylines over a map. Two types of markers are supported. You can either use the predefined standard markers or include your own image resources with your application and use custom markers. The following example shows how to add a MapStandardMarker:

MapStandardMarker marker = mapFactory.createStandardMarker (new GeoCoordinate(55.583, 13.033,0));
map.addMapObject(marker);

Accessing Online Services

The Maps for Java ME API provides access to online services such as search and routing. Search is able to specify a GeoCoordinate for an address or vice versa, and can retrieve a list of points of interest nearby. It can also be queried for more details about a point of interest. The routing service may be used to find a way to travel between two or more GeoCoordinates. For further details on how to use these services please check the routing and search examples.

Other resources

  • Maps and Location APIs
  • Have a look at what other technologies are availabe for developing location-based services.
  • API key
  • Use your credentials to increase permitted load accessing maps and location services and other benefits.
  • Discussion
  • Discover the latest news about the API in the discussion forums
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved