hello friends
i'm a newbie
I have displayed map.
but I would like to add pictures on the map.
how to display images on a map?
Printable View
hello friends
i'm a newbie
I have displayed map.
but I would like to add pictures on the map.
how to display images on a map?
have you considered on checking the API docs, or maybe wiki examples ? Here's link to one which should get you started: [url]http://www.developer.nokia.com/Community/Wiki/Adding_Markers_to_the_Map_with_Maps_API_for_Java_ME[/url]
thank you for your help.
I was able to display images on the map
but I want to put a picture on the bottom right of the screen.
how to set the picture in the bottom right of the screen.
Thank you
Look at the [B]MapMarker [/B]class If you want to put pictorial icons rather than Balloon push-pins onto your map. The basic map components anchor to the globe via [B]GeoCoordinates [/B] so will move with the map.
if however you want to add a static image as an attribution for an overlay or something. you'll need something to anchor to the [B]MapDisplay[/B] via [B]Points[/B], so you'll have to create a custom [B]MapComponent[/B] to do this.
Here is an Attribution Map Component - attach it to the map in the usual way.
[CODE]
AttributionMapComponent attribution = new AttributionMapComponent(loadAttributionImage(), 2, 0x000000,
0xFFFFFF);
map.addMapComponent(attribution);
[/CODE]
Where the attribution [B]image [/B]is taken from the resources of the app.
[CODE]
private Image loadAttributionImage() {
// load image resource from MIDlet's jar file
Image im = null;
try {
im = Image.createImage("/NLS.png");
} catch (IOException io) {
throw new IllegalStateException("no attribution found.");
}
return im;
}
[/CODE]
I've written the following [B]MapComponent [/B] to put an un-moving attribution image over the map. It displays if an overlay is present. ([B]map.getAllMapOverlays().length > 0[/B])
[CODE]public class AttributionMapComponent implements MapComponent {
private final String id = "attribution";
private final String version = "1.0";
private final Image attribution;
private MapDisplay map;
private static final int SMALL_CORNER_ARC = 5;
private static final int Y_OFFSET = 5;
private static final int X_OFFSET = 5;
private static final int NO_FILL = -1;
private final int border;
private final int borderColor;
private final int backgroundColor;
private Point borderAnchor;
private Point backgroundAnchor;
public AttributionMapComponent(Image attribution,int border, int borderColor,
int backgroundColor) {
this.attribution = attribution;
this.border = border;
this.borderColor = borderColor;
this.backgroundColor = backgroundColor;
}
public AttributionMapComponent(Image attribution) {
this(attribution, 0, NO_FILL, NO_FILL);
}
// from MapComponent
public void attach(MapDisplay map) {
this.map = map;
this.borderAnchor = new Point(map.getWidth() - attribution.getWidth() - border - X_OFFSET,
map.getHeight() - attribution.getHeight() - Y_OFFSET - border);
this.backgroundAnchor = new Point(map.getWidth() - attribution.getWidth() - X_OFFSET,
map.getHeight() - attribution.getHeight() - Y_OFFSET);
return;
}
// from MapComponent
public void detach(MapDisplay map) {
this.map = null;
return;
}
// from MapComponent
public String getId() {
return id;
}
// from MapComponent
public String getVersion() {
return version;
}
// from MapComponent
public void mapUpdated(boolean zoomChanged) {
}
// from MapComponent
public void paint(Graphics g) {
if (map != null && map.getAllMapOverlays().length > 0) {
if (border > 0) {
g.setColor(borderColor);
g.fillRoundRect(borderAnchor.getX(), borderAnchor.getY(),
attribution.getWidth() + (border * 2), attribution.getHeight() + (border * 2),
SMALL_CORNER_ARC, SMALL_CORNER_ARC);
}
if (backgroundColor > NO_FILL) {
// Draw the background.
g.setColor(backgroundColor);
g.fillRoundRect(backgroundAnchor.getX(), backgroundAnchor.getY(),
attribution.getWidth(),
attribution.getHeight(), SMALL_CORNER_ARC, SMALL_CORNER_ARC);
}
g.drawImage(attribution,
backgroundAnchor.getX(), backgroundAnchor.getY(),
Graphics.TOP | Graphics.LEFT);
}
}
public EventListener getEventListener() {
return null; // add eventHandler here if necessary.
}
}[/CODE]
[QUOTE=a.pinturicchio;893901]
... I want to put a picture on the bottom right of the screen.
how to set the picture in the bottom right of the screen.
Thank you[/QUOTE]
An article on creating a framework for Custom [B]MapComponents[/B] which includes adding a static image at any corner of the map has just been submitted to the Community Wiki:
[url]http://www.developer.nokia.com/Community/Wiki/Creating_Touchable_Custom_Map_Components_for_the_Maps_API_for_Java_ME#TouchableDisplayComponent[/url]
[QUOTE=jasfox;894415]An article on creating a framework for Custom [B]MapComponents[/B] which includes adding a static image at any corner of the map has just been submitted to the Community Wiki:
[url]http://www.developer.nokia.com/Community/Wiki/Creating_Touchable_Custom_Map_Components_for_the_Maps_API_for_Java_ME#TouchableDisplayComponent[/url][/QUOTE]
Ok thnks you si