×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    54

    How to create a marker tooltip showing Your current Location

    Hi, My app is Friends and Family Loactor!! I want to create a tooltip on my nokia maps which will show my current location(i.e. Street address ) on that tooltip !!! I am using RevGeocoding which is showing me alert displaying the address of that particular location. but i want to show a tip which will display the street adresss as well as the time when tracked!!!


    How can i do this? i have followed example provided on this link.. http://www.developer.nokia.com/Commu...xt_to_a_marker

    but it did not help me!!!

    plzz help asap!!

    Thanks
    Vinita!!!

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to create a marker tooltip showing Your current Location

    In what way did it not help? Did you try downloading the sample code and running that?

    I'd suggest you get the example working, then figure out how to lift the necessary classes (TooltipComponent, TooltipText and TooltipRenderer) from the example MIDlet into your own.

    Or, what problem are you having with the example?

    Graham.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    54

    Re: How to create a marker tooltip showing Your current Location

    Quote Originally Posted by grahamhughes View Post
    In what way did it not help? Did you try downloading the sample code and running that?

    I'd suggest you get the example working, then figure out how to lift the necessary classes (TooltipComponent, TooltipText and TooltipRenderer) from the example MIDlet into your own.

    Or, what problem are you having with the example?

    Graham.
    yaa i created a new project and tried running that example!! it is not giving me any error or sumthng but the tooltip showing the location info. is not being displayed!!!

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to create a marker tooltip showing Your current Location

    I'm running it now... you have to drag the blue marker into the centre of the screen for the caption to appear...

  5. #5
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to create a marker tooltip showing Your current Location

    also are you running it on a device or on the emulator ? And if its on a device does it have GPS activated ?
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  6. #6
    Registered User
    Join Date
    Jan 2013
    Posts
    54

    Re: How to create a marker tooltip showing Your current Location

    I'm running it now... you have to drag the blue marker into the centre of the screen for the caption to appear...?
    Yes sir it is working now!!! Thanks

  7. #7
    Registered User
    Join Date
    Jan 2013
    Posts
    54

    Re: How to create a marker tooltip showing Your current Location

    Quote Originally Posted by grahamhughes View Post
    I'm running it now... you have to drag the blue marker into the centre of the screen for the caption to appear...
    Sir i am using the same code but i am getting the tooltip automatically attached with the marker at bottom.... but what if i want it on mouse press event what will i have to do?
    Last edited by angelvini210; 2013-03-24 at 16:23.

  8. #8
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to create a marker tooltip showing Your current Location

    Please don't call me "sir"... I'm not your father.

    I know what you mean... it's not a tiny example. And the Maps API isn't exactly "minimal".

    I managed to get a simple example working. It's quite different from the other example code you've looked at, as I didn't try taking that code apart, I just started from scratch. And I'm not sure it does what you want. But take a look...

    MapMidlet.java
    Code:
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    import com.nokia.maps.common.ApplicationContext;
    
    public class MapMidlet extends MIDlet implements CommandListener {
        
        private Map map;
    
        protected void startApp() throws MIDletStateChangeException {
            if (map == null) {
                ApplicationContext appcon = ApplicationContext.getInstance();
                appcon.setAppID("SomeId");
                appcon.setToken("SomeToken");
                
                Display display = Display.getDisplay(this);
                map = new Map(display);
                
                map.addMarker(53.2944, -2.75, "Home");
                
                map.addCommand(new Command("Exit", Command.EXIT, 0));
                map.setCommandListener(this);
                display.setCurrent(map);
            }
        }
    
        protected void destroyApp(boolean must) throws MIDletStateChangeException {
            // do nothing
        }
    
        protected void pauseApp() {
            // do nothing
        }
    
        public void commandAction(Command c, Displayable d) {
            if (c.getCommandType() == Command.EXIT) {
                notifyDestroyed();
            }
        }
    }
    Map.java
    Code:
    import java.util.Hashtable;
    
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;
    
    import com.nokia.maps.common.GeoCoordinate;
    import com.nokia.maps.map.MapCanvas;
    import com.nokia.maps.map.MapFactory;
    import com.nokia.maps.map.MapObject;
    import com.nokia.maps.map.Point;
    import com.nokia.mid.ui.DirectGraphics;
    import com.nokia.mid.ui.DirectUtils;
    
    public class Map extends MapCanvas {
        
        private Hashtable captions = new Hashtable();
        private String currentCaption;
    
        public Map(Display display) {
            super(display);
        }
        
        public void addMarker(double latitude, double longitude, String caption) {
            MapFactory f = getMapFactory();
            GeoCoordinate coord = new GeoCoordinate(latitude, longitude, 0);
            MapObject marker = f.createStandardMarker(coord);
            getMapDisplay().addMapObject(marker);
            captions.put(marker, caption);
        }
    
        public void onMapContentComplete() {
            // do nothing
        }
    
        public void onMapUpdateError(String description, Throwable detail, boolean critical) {
            System.err.println(description + ": " + detail.getMessage());
        }
    
        protected void paint(Graphics g) {
            super.paint(g);
            if (currentCaption != null) {
                Font font = Font.getDefaultFont();
                g.setFont(font);
                DirectGraphics dg = DirectUtils.getDirectGraphics(g);
                dg.setARGBColor(0xccffffff);
                g.fillRect(0, 0, getWidth(), font.getHeight());
                dg.setARGBColor(0xff000000);
                g.drawString(currentCaption, 0, 0, Graphics.TOP | Graphics.LEFT);
            }
        }
    
        protected void pointerPressed(int x, int y) {
             Point p = new Point(x, y);
             MapObject marker = getMapDisplay().getObjectAt(p);
             currentCaption = (String) captions.get(marker);
             repaint();
        }
    
        protected void pointerReleased(int x, int y) {
            currentCaption = null;
            repaint();
        }
    }
    Graham.

Similar Threads

  1. MH5 Get Current location
    By tomgiam in forum [Archived] MH5: Nokia Maps Framework for mobile HTML5
    Replies: 5
    Last Post: 2013-03-20, 22:01
  2. Replies: 2
    Last Post: 2010-08-30, 12:03
  3. Showing the current position using the Google Maps API
    By chandran.biju007 in forum Symbian
    Replies: 0
    Last Post: 2010-04-29, 07:47
  4. How to get current GPS location
    By videoFx in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2009-04-07, 06:46
  5. Current Location
    By marc_garraway in forum Mobile Java General
    Replies: 7
    Last Post: 2008-10-17, 18:33

Posting Permissions

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