Mobile Map API

MGMaps Lib SDK is professional toolkit to develop mobile mapping applications.
Platforms: iPhone, Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »

Uudised

Viimane: Thu, 29 Jul 2010 19:38:21
Teema: New maps SDK release 1.1.0
Veel uudiseid »

Nutiteq Twitteris

11 weeks 1 day ago Nutiteq is proud sponsor of StateOfTheMap 2010 #sotm10

Lib SDK with LWUIT

LWUIT is a fancy J2ME user interface library from Sun. It is free to use and it gives nice animations for modern phones.

However, it has own specific methods for many UI control features (including canvas), so in principle you need to rewrite application specifically to use the LWUIT. It does not provide automatic "polishing" tools like e.g. J2ME Polish does.

With MGMaps Lib SDK the trick to draw MapComponent on LWUIT Image object, that can be painted on any component.

To paint on LWUIT image we need to retrieve J2ME native Graphics object from the image. For that a wrapper class can be used:

package com.sun.lwuit;

public class ImageWrapper {
  private final Image image;

  //Image is from LWUIT package
  public ImageWrapper(final Image lwuitBuffer) {
    this.image = lwuitBuffer;
  }
  
  public javax.microedition.lcdui.Graphics getGraphics() {
    return (Graphics) image.getGraphics().getGraphics();
  }
}

All it does is exposing J2ME graphics object from LWUIT image.

Sample usage of MapComponent and ImageWrapper:

public class LWUITMapScreen extends Component implements MapListener {
  private MapComponent mapComponent;
  private Image lwuitBuffer;
  private javax.microedition.lcdui.Graphics bufferGraphics;

  public LWUITMapScreen() {
    //create map component
    mapComponent = null; 
    //create buffer image that can be used to paint on LWUIT element
    lwuitBuffer = Image.createImage(100, 100);
    //retrieve J2ME graphics object from buffer image
    bufferGraphics = new ImageWrapper(lwuitBuffer).getGraphics();
  }

  public void paint(final Graphics g) {
    //paint on the graphics object retrieved with wrapper.
    //this is effectively same as painting on LWUIT image
    mapComponent.paint(bufferGraphics);
    //paint the image, now containing map, on Component (that is visible on screen)
    g.drawImage(lwuitBuffer, 0, 0);
  }
}

This is just a sample, how to draw map on a LWUIT image. By using wrappers for different elements (to expose J2ME Graphics from the element), the map can be drawn to any LWUIT element imaginable.

FailinimiSuurus
lwuit_libsample.zip1.21 MB
Lisa kommentaar

LWUIT + Nutiteq

Please I tried this example to use Nutiteq with LWUIT. I got an error with image.getGraphics().getGraphics();
saying that the method getGraphics is not public and cannot be used.

Please can you help?

Thanks.

Create your ImageWrapper in

Create your ImageWrapper in package com.sun.lwuit and it should work!

i tried this cod but it but

i tried this cod but it doesn't work :(
please its there someone who can help me im stuck!!

See attached sample project.

See attached sample project. It is based on Eclipse and with Mobile Tools for Java (MTJ) plug-in. It includes LWUIT 1.3 (latest now) and latest beta version of maps lib. Note that the mapping lib is tweaked a bit to get it working, so you may get errors with earlier library versions (I got it with Place listing, not with maps).

/JaakL

Solution for LWUIT imagewrap

I had the same problem.

The solution is to place imagewrapper in the folder com.sun.lwuit;
hence have "package com.sun.lwuit;"
and
"import javax.microedition.lcdui.Graphics;"
with latest lwuit lib