2010年4月20日 星期二

J2ME Wireless Toolkit GPS (jsr179)

Target: GPS application
Design Flow: 1. 利用 J2ME Wireless Toolkit (JSR179),取得經緯度位置, La = get Latitude(); //取得緯度 Ln = get Longitude(); //取得經度 2.在用Html request的方式透過http://tinygeocoder.com/create-api.php?g=”+lat+”,”+lon,取得我們易懂的位置. La = 33.790348 Ln = 117.226085 example: http://tinygeocoder.com/create-api.php?g=33.790348,-117.226085 3. 最後可以結合 Google Map Display. Flow Chart Sample Code: Get La,Ln
        Coordinates c;
        // Set criteria for selecting a location provider:
        // accurate to 500 meters horizontally
        Criteria cr= new Criteria();
        cr.setHorizontalAccuracy(5000);
        cr.setVerticalAccuracy(5000);
    // Get an instance of the provider
        lp= LocationProvider.getInstance(cr);

        // Request the location, setting a one-minute timeout
        l = lp.getLocation(120);
        c = l.getQualifiedCoordinates();

        if(c != null ) {
          // Use coordinate information
          double La = c.getLatitude();
          double Ln = c.getLongitude();
          string = "\nLatitude : " + La + "\nLongitude : " + Ln;
          new GetData(midlet,La,Ln).start();

        } else {
            string ="Location API failed";
        }

2 則留言:

  1. May i know, only wireless tool kit enough for execute the J2ME programs and applications?

    Cegonsoft

    回覆刪除
  2. you're right, this is only for Java(J2ME) based Mobile phone.

    回覆刪除