CloudMade is a company which provide services and support on top of OpenStreetMap datas. It’s very easy to integrate CloudMade with J2memap. To do this, let’s take our hello world example, and put cloud made data instead of default map datas. You just need a CloudMade API Key, so contact CloudMade for this.
The cloudMade URL are very simple, something like this:
http://tiles.cloudmade.com/APIKEY/2/256/!z!/!x!/!y!.png
Where APIKEY is your cloudmade APIKey….
So to support this in J2memap, we just use the GenericOverlay class, and adding the cloudmade URL, like this:
GenericOverlay cloudMade=new GenericOverlay(”CloudMade”,”http://tiles.cloudmade.com/APIKEY/2/256/!z!/!x!/!y!.png”);
myMap.setMapProvider(0,openStreeMap);
The complete exemple is here:
import com.eightmotions.map.*;
import com.eightmotions.util.UtilMidp;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;/**
* CloudMade iterface from J2meMap
*/
public class MyOpenPos extends MIDlet implements MapDisplayListener,CommandListener,Runnable{
MapDisplay myMap;
Display m_disp;
public void startApp() {
m_disp=Display.getDisplay(this);
UtilMidp.checkMIDP(this);
myMap=new MapDisplay();
m_disp.setCurrent(myMap.getCanvas());
GenericOverlay cloudMade=new GenericOverlay(”CloudMade”,”http://tiles.cloudmade.com/APIKEY/2/256/!z!/!x!/!y!.png”);
myMap.setMapProvider(0,openStreeMap);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}