×

Discussion Board

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

    [ASK] My Position with JSR-179 in Nokia Map

    hi, i'm arif..

    I make application use nokia map
    I display my current position with jsr 179.
    but When I move, the marker (my position marker) is not move..

    this my code:
    Code:
    mnUtm midlet;
        Display display;
        MapCanvas mapCanvas;
        MapDisplay mapDisplay;
        MapFactory mapFactory;
        Command cmKembali, cmMenu, cmInfo ;
        LocationProvider lp;
        WaypointParameterList wpl;
        MapStandardMarker pos;
        skalaMap skala;
        legendaMap kompas;
        String string;
        Alert info;
    
    public mnPosisiku (mnUtm midlet, Display display) {
            this.midlet = midlet;
            this.display = display;
            wpl = new WaypointParameterList();
            skala = new skalaMap();
            kompas = new legendaMap();
        }
    
        public void pos() {
          try {
          //Make MapCanvas
            mapCanvas = new MapCanvas(display);
            mapDisplay = mapCanvas.getMapDisplay();
    
          //Make Command
            cmKembali = new Command("Kembali", Command.BACK, 0);
            cmInfo = new Command("Info", Command.OK, 1);
            mapCanvas.addCommand(cmKembali);
            mapCanvas.addCommand(cmInfo);
            mapCanvas.setCommandListener(this);
            
         //Current position with JSR-179
            Criteria cr = new Criteria();
            cr.setHorizontalAccuracy(500);
    
            lp = LocationProvider.getInstance(cr);
    
            Location l = lp.getLocation(60);
            Coordinates c = l.getQualifiedCoordinates();
    
                if (c != null) {
                        double lat = c.getLatitude();
                        double lon = c.getLongitude();
      
            mapCanvas.getMapDisplay().setCenter(new GeoCoordinate(lat, lon, 0));
            mapCanvas.getMapDisplay().setZoomLevel(16,0,0);
    
         //Make marker (my current position) in Map
           Point center = new Point(mapCanvas.getWidth()/2, mapCanvas.getHeight()/2);
           GeoCoordinate gc = mapDisplay.pixelToGeo(center);
           wpl.addCoordinate(gc);
           pos = mapCanvas.getMapFactory().createStandardMarker(gc, 10, null, MapShapeType.bed);
           mapDisplay.addMapObject(pos);
           mapDisplay.addMapComponent(skala);
           mapDisplay.addMapComponent(kompas);
           mapCanvas.setTitle("Posisi Saat Ini");
    
           string = "Posisi Anda Saat ini Berada di :" +
                            "\nLatitude : " + lat + "\nLongitude : " + lon;
    
         //Display Map
            display.setCurrent(mapCanvas);
        
                }
    
        } catch (Exception ex) {
            ex.printStackTrace();
            }
        }
    
        public void commandAction(Command c, Displayable d) {
          //Back to Main Menu
            if (c == cmKembali) {
               display.setCurrent(midlet.menu);
               }
               //Display Coordinates my position
                if (c == cmInfo) {
                    info = new Alert("Detail Posisi", string, null, AlertType.INFO);
                    info.setTimeout(60000);
                    display.setCurrent(info, mapCanvas);
                }
        }
    }
    How to move my position marker when I move? (Real-time position)

    please help me
    thank you
    Last edited by Arif_Mubashir; 2012-06-04 at 14:28.

  2. #2
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: [ASK] My Position with JSR-179 in Nokia Map

    if you want marker always to be at the center then you need to update the marker while listening to maps move events.
    something like this
    Point center = new Point(map.getWidth() / 2, map.getHeight() / 2);
    GeoCoordinate gc = map.pixelToGeo(center);
    Marker marker =/..marker instance*/
    map.addMapObject(marker);

  3. #3
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: [ASK] My Position with JSR-179 in Nokia Map

    When I move, the marker (my position marker) is not move..
    Do you get a new set of coordinates? You don't seem to update your location. You seem to only retrieve it once. Apart from the Nokia Maps API that helps you display the map and the marker on your current location, you would need to get updates on your location in frequent intervals. I would suggest that you attach a location listener to your location provider and retrieve the location updates via the locationUpdated method. You can find more information about listening to location updates here

Similar Threads

  1. How can i move/drag to a position,a nokia.maps.map.StandardMarker with a button event
    By upixsoul in forum [Archived] Maps API for Javascript
    Replies: 2
    Last Post: 2012-06-04, 17:20
  2. Nokia N95 network gps position finding problem in J2ME?
    By DileepKumar in forum Mobile Java General
    Replies: 1
    Last Post: 2012-01-02, 16:08
  3. Replies: 0
    Last Post: 2011-09-14, 11:03
  4. J2ME Location API vs. Nokia Series 40 Position API
    By keyang_huang in forum Mobile Java General
    Replies: 1
    Last Post: 2005-04-27, 08:39

Posting Permissions

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