Hi azakharo,
So first you need to find a way to catch the click on the marker and then you need to change the marker to a tooltip.
If a marker is not clicked, how should it look like? Can it be a standard marker (like a balloon) or not?
Also, after the marker is clicked, what kind of information do you need in the tooltip (i.e. are you happy with a map marker with a custom icon)?
The first part of catching the click on the marker can be done as follows (in this example I used standard markers and I just change their shape):
Main MIDlet:
Code:
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class NokiaMapsMIDlet extends MIDlet
{
Display display;
MapCanvasImpl mapcanvas;
public void startApp()
{
//ApplicationContext ctx = ApplicationContext.getInstance();
//ctx.setAppID("MyAppId");
//ctx.setToken("MyToken");
display = Display.getDisplay(this);
mapcanvas = new MapCanvasImpl(display);
display.setCurrent(mapcanvas);
}
public void destroyApp(boolean unconditional){}
public void pauseApp() {}
}
Supporting class:
Code:
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import com.nokia.maps.common.GeoBoundingBox;
import com.nokia.maps.common.GeoCoordinate;
import com.nokia.maps.map.MapCanvas;
import com.nokia.maps.map.MapDisplay;
import com.nokia.maps.map.MapShapeType;
import com.nokia.maps.map.MapStandardMarker;
import com.nokia.maps.map.Point;
public class MapCanvasImpl extends MapCanvas
{
GeoCoordinate markergeo;
GeoBoundingBox markerbox;
MapStandardMarker marker;
MapDisplay mapdisplay;
GeoCoordinate clickgeo;
public MapCanvasImpl(Display display)
{
super(display);
mapdisplay=getMapDisplay();
markergeo=new GeoCoordinate(41.90311, 12.49576, 0.0f);
marker = getMapFactory().createStandardMarker(markergeo, 48, null, MapShapeType.baloon);
markerbox=marker.getBoundingBox();
mapdisplay.addMapObject(marker);
}
protected void pointerPressed(int x, int y)
{
super.pointerPressed(x, y);
clickgeo=mapdisplay.pixelToGeo(new Point(x,y));
if(markerbox.contains(clickgeo))
{
if(marker.getShapeType()==MapShapeType.baloon)
{
marker.setShapeType(MapShapeType.star);
GeoCoordinate newgeo=new GeoCoordinate(41.90312, 12.49576, 0.0f);
marker.setCoordinate(newgeo);
}
else
{
marker.setShapeType(MapShapeType.baloon);
GeoCoordinate newgeo=new GeoCoordinate(41.90311, 12.49576, 0.0f);
marker.setCoordinate(newgeo);
}
repaint();
}
}
protected void paint(Graphics g)
{
super.paint(g);
markerbox=marker.getBoundingBox();
}
}
Please note that there is currently a bug in the library (version 0.5) where the repaint doesn't update the map if the marker has changed shape, while it does, if the marker has changed coordinates.