Revision as of 14:44, 8 November 2011 by skalogir (Talk | contribs)

How to create custom Map View in Java ME

From Nokia Developer Wiki
Jump to: navigation, search

{{This article explains how to retrieve the available map views and apply one of them to your custom Maps by using Nokia Maps API for Java ME. This makes it possible to display a location by using aerial satellite images. Hybrid and terrain modes are also available.}}



Nokia Maps API for Java ME uses the MapProvider class in order to display the available view modes. MapProvider is a base class used to identify a provider for layered map information. Map providers are divided into those providing data for a base map and those providing data for a transparent overlay layer that can be added on top of the base map (e.g. traffic overlay). Satellite, hybrid, terrain and normal map displays are regarded as the base map on top of which, one can add overlays. Each map mode (hybrid, satellite, normal, terrain) corresponds to one MapProvider. The MapDisplay class, supports retrieval of the available base maps, by calling the getAvailableBaseMap method. This returns an array of MapProvider objects. Iterating through the items of the array, allows to get information about the view and eventually apply it, by calling the setBaseMapType method.

Integration of Nokia Maps API for Java ME into the project

As of version 0.5, Nokia Maps API for Java ME is provided as a separate library. The link provided at the bottom of this page, redirects to the location where the API, including documentation and the .jar file, can be downloaded.

Implementing the mapsCustomView midlet

import com.nokia.maps.map.MapCanvas;
import com.nokia.maps.map.MapDisplay;
import com.nokia.maps.map.MapFactory;
import com.nokia.maps.map.MapProvider;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;
public class mapsCustomView extends MIDlet implements CommandListener
Display display;
MapCanvas mapcanvas;
MapDisplay mapdisplay;
MapProvider[] providers;
MapFactory mapfactory;
ChoiceGroup allBaseMaps;
Command parentCommand;
Command[] options;
public void startApp()
mapcanvas = new MapCanvas(display);
options=new Command[providers.length];
for(int i=0;i<providers.length;i++)
String thisoption=providers[i].getName();
options[i]=new Command(thisoption,Command.HELP,5);
mapcanvas.addCommand(options[i]); }
public void pauseApp()
{ }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command c, Displayable arg1)
for(int i=0;i<options.length;i++)

See also

Nokia Maps API for Java ME

Article Metadata
Code ExampleTested with
Devices(s): X3-02
Device(s): All
Dependencies: Nokia Maps API for Java ME v0.5
Keywords: Location API, Ovi Maps, Form, CustomItem, Gauge
Created: jappit (28 Jun 2011)
Reviewed: skalogir (06 Oct 2011)
Last edited: skalogir (08 Nov 2011)
308 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.