How to display Nokia Maps.
Hi, I am just learning J2ME. Can any one tell me why the code below fails to display a map but insteady displays a blank screen:
/* HelloMapMidlet */
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simo.map;
import com.nokia.maps.common.ApplicationContext;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
/**
* @author simon
*/
public class HelloMapMIDlet extends MIDlet{
public HelloMapMIDlet()
{
}
public void startApp() {
// Get your own app_id and token by registering at
// [url]https://api.developer.nokia.com/ovi-api/ui/registration[/url]
ApplicationContext.getInstance().setAppID(" ");
ApplicationContext.getInstance().setToken(" ");
Display display = Display.getDisplay(this);
MyMapCanvas hellomap = new MyMapCanvas(display, this);
display.setCurrent(hellomap);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
/* MyMapCanvas*/
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author simon
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simo.map;
import com.nokia.maps.common.GeoCoordinate;
import com.nokia.maps.map.MapCanvas;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
/**
* @author simon
*/
public class MyMapCanvas extends MapCanvas implements CommandListener{
private final Command EXIT = new Command("Exit", Command.EXIT, 1);
protected MIDlet midlet; // for notifyDestroyed
public MyMapCanvas(Display display, MIDlet midlet) {
super(display);
this.midlet = midlet;
addCommand(EXIT);
setCommandListener(this);
getMapDisplay().setZoomLevel(10, 0, 0);
getMapDisplay().setCenter(new GeoCoordinate(52.5, 13.4, 0));
}
/*
public void paint1(Graphics g){
paint(g);
}
*/
public void commandAction(final Command c, Displayable d) {
if (c == EXIT) {
midlet.notifyDestroyed();
} else {
commandRun(c);
}
}
protected void commandRun(Command c) {
// handle any other command
}
public void onMapUpdateError(String string, Throwable thrwbl, boolean bln) {
// add code for update error handling
}
public void onMapContentComplete() {
// add code for content updated handling
}
}
Re: How to display Nokia Maps.
Because of that:
[QUOTE]Get your own app_id and token by registering at
// [url]https://api.developer.nokia.com/ovi-api/ui/registration[/url][/QUOTE]
You need to register for accesing Nokia Maps API and you need to provide AppID and Token in code
Re: How to display Nokia Maps.
Even when I include the AppID and Token, the map is not display but only displays the word "NOKIA" at the bottom.
Re: How to display Nokia Maps.
Try to reduce the Zoom level and try to display different co-ordinates.
Re: How to display Nokia Maps.
I tried changing co-ordinates and zoom level but there was no change. it only displays the word "0.20KB" at the top right corner, zoom symbols: "+" and "-" in the middle and the word "Nokia" on the bottom-left corner. The map lines are not displayed.
Re: How to display Nokia Maps.
Also, please download the latest 1.1 Maps, you appear to be using some older version (the intialization is actually different)
Get the latest from: [url]http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/[/url]
Note that the code in: [url]https://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/Getting_started/[/url] is incorrect, instead use code from: [url]https://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/Code_examples/[/url]
More examples can be found from: [url]http://www.developer.nokia.com/Community/Wiki/Examples_for_Maps_API_for_Java_ME[/url]
Re: How to display Nokia Maps.
Thank you for the assistance but I seem to get the same results even with the newly downloaded Nokia Maps Api. I even tried to run examples that come with Nokia Maps Api but I got the same results.
Re: How to display Nokia Maps.
Be sure your simulator can access internet properly.
Re: How to display Nokia Maps.
I thought I only need to use an emulator for testing Maps Apps. I request you to throw more light on the need for a simulator that is connected to internet?
Re: How to display Nokia Maps.
Basically people mix emulator & simulator here all the time.
What he means that, you should check that you do have internet connectivity with the emulator you are using, or if you use a real device, see that it has internet connectivity.
Re: How to display Nokia Maps.
Thanks guys, it has worked. the problem was with my internet connection.
Re: How to display Nokia Maps.
[QUOTE=symbianyucca;909176]Basically people mix emulator & simulator here all the time.[/QUOTE]
Please tell us the difference.
Thanks!
Re: How to display Nokia Maps.
[QUOTE=r60600;909305]Please tell us the difference.
Thanks![/QUOTE]
Difference is that if you do not have internet connection, you wont be seeing any map. and once you get the internet working in your development environment, the maps data will be downloaded and thus you will be able to see the map.