×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    6

    display image in nokia API

    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?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: display image in nokia API

    have you considered on checking the API docs, or maybe wiki examples ? Here's link to one which should get you started: http://www.developer.nokia.com/Commu...PI_for_Java_ME

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    6

    Re: display image in nokia API

    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

  4. #4
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: display image in nokia API

    Look at the MapMarker 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 GeoCoordinates 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 MapDisplay via Points, so you'll have to create a custom MapComponent 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);
    Where the attribution image 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;
        }
    I've written the following MapComponent to put an un-moving attribution image over the map. It displays if an overlay is present. (map.getAllMapOverlays().length > 0)

    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.
        }
    }

  5. #5
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: display image in nokia API

    Quote Originally Posted by a.pinturicchio View Post
    ... 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
    An article on creating a framework for Custom MapComponents which includes adding a static image at any corner of the map has just been submitted to the Community Wiki:
    http://www.developer.nokia.com/Commu...splayComponent

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    6

    Re: display image in nokia API

    Quote Originally Posted by jasfox View Post
    An article on creating a framework for Custom MapComponents which includes adding a static image at any corner of the map has just been submitted to the Community Wiki:
    http://www.developer.nokia.com/Commu...splayComponent
    Ok thnks you si

Similar Threads

  1. Display Large Image on device's display
    By fecxelmin in forum Mobile Java General
    Replies: 4
    Last Post: 2010-04-22, 10:24
  2. Replies: 0
    Last Post: 2009-03-03, 22:51
  3. Unable to display image on Nokia n95 emulator
    By azar_sheik in forum General Development Questions
    Replies: 1
    Last Post: 2008-10-23, 11:02
  4. JPEG image display on Nokia Series 60 emulator
    By Nokia_Archive in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2007-09-18, 05:38
  5. JPEG image display on Nokia Series 60 emulator
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-06-02, 00:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×