6

ブラックベリーマップの代わりにブラックベリーアプリケーション開発でGoogleマップを使用する方法を誰かに教えてもらえますか?

4

3 に答える 3

9

最近、Browser.FieldからGoogle MapsのWebサイトを使用することを考えましたGMapsはJavaScriptに基づいており、Blackberryネイティブブラウザーで十分にサポートされていないため、使用できません。

実際、BlackberryでGoogleマップを使用する方法は2つあります。

于 2009-10-07T12:03:39.413 に答える
0

ここに小さな例があります:

Googleマップの静止画像を表示するためのフォーム:

public class frmMap extends Form implements CommandListener {

    Command _back;
    MIDlet midlet;
    Form dis;

    public frmMap(String title, ImageItem img, MIDlet m, Form d){
        super(null);

        this.midlet = m;
        this.dis = d;

        _back = new Command("Back", Command.BACK, 1);
        addCommand(_back);
        append(img);
        setCommandListener(this);        
    }

    public void commandAction(Command c, Displayable d) {
        if(c == _back){
            Display.getDisplay(midlet).setCurrent(dis);
        }
    }

}

静止画像をダウンロードするためのクラスinetクラス:

public class INETclass implements Runnable {

    private String _location = null;
    private HttpConnection inet;
    private Pispaal _m;
    public String url = null;

    public INETclass(String location, Pispaal m){
        _location = location;
        _m = m;        
    }

    public void run() {
        try
        {
            //Setup the connection
            inet = (HttpConnection)Connector.open(url);
            inet.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            int rc = inet.getResponseCode();

            //Responsecode controleren
            if(rc == HttpConnection.HTTP_OK){
                //Open input stream to read the respone
                DataInputStream is = new DataInputStream(inet.openInputStream());                
                StringBuffer sb = new StringBuffer();

                int ch;
                long len = -1;
                byte[] buffer = null;
                if(_location == null){
                    len = is.available();
                }

                if(len != -1){
                    if(_location == null){
                        buffer = IOUtilities.streamToBytes(is);
                    }else{
                        while((ch = is.read()) != -1){
                            sb.append((char)ch);
                        }
                    }
                }
                is.close();

                if(_location == null){
                    _m.OnINETComplete(buffer);
                }else{
                    _m.Alert(sb.toString());
                }
            }else{
                _m.Alert("URL " + url + " geeft response code: " + rc);
                try
                {
                    inet.close();
                }catch(Exception e){
                    _m.Alert("Error: " + e.getMessage());
                }
            }

        }
        catch(Exception e)
        {
            _m.Alert("Error: " + e.getMessage());
            System.out.println("Error: " + e.getMessage());
        }
        finally
        {
            try
            {
                if(inet != null){ inet.close(); }  
                Thread.currentThread().join(); //Making sure this thread dies
            }catch(Exception e){
                _m.Alert("Error: " + e.getMessage());
                System.out.println("Error: " + e.getMessage());
            }
        }
    }
}

ダウンロードを開始するボタンアクションと、画像を表示するためにフォームをロードするコールバックアクション

public void commandAction(Command c, Displayable d) {
        synchronized(c){
            String loc = _location.getText();
            if(loc.indexOf(",") > 0){
                //if(c == _strCommand){                
                    //INETclass inet = new INETclass(loc, this);
                    //Thread tInet = new Thread(inet);
                    //tInet.start();
                    //Alert("Locatie word doorgestuurd. Even geduld");
                //}else 
                if(c == _mapView){
                    INETclass inet = new INETclass(null, this);
                    inet.url = "http://www.qeueq.com/gmap.php?location=" + this.lat + "," + this.lon + "&size=" + this.width + "x" + this.height + ";deviceside=true";
                    Thread tInet = new Thread(inet);
                    tInet.start();
                }
            }else{
                Alert("GPS locatie is nog niet beschikbaar.");
            }
        }
    }

public void UpdateLocation(double lat, double lon){
       String location = lat + "," + lon;
       this.lat = lat;
       this.lon = lon;
       synchronized(location){
           _location.setText(location);
            INETclass inet = new INETclass(location, this);
            Thread tInet = new Thread(inet);
            tInet.start();           
       } 
    }

ニーズに合うようにコードを改良および編集します。それを正しくするために私に少し時間がかかりました。

于 2012-01-24T20:53:27.700 に答える
0

画像のように独自のデータでBlackBerryマップの代わりにGoogleマップを使用できるようになりました。 ここに画像の説明を入力してください

あなたがあなた自身の場所/マーカーを示すためにグーグルマップを使用することを探しているなら、あなたはApplicationDescriptorあなたのアプリケーションから使用してグーグルマップを呼び出すことができます。それを使用してデバイス上のグーグルマップをチェックするCodeModuleManager.getModuleHandle("GoogleMaps");と、整数が返されます。ゼロ以外の場合は、それが利用可能であることを意味します。次に、KMLファイルに場所を追加できます。また、KMLファイルタグを使用して場所のポインタをカスタマイズすることもできます。

Maxによってリンクされた例では、単一のマーカーのみが許可されます。そのため、複数のマーカーを追加する場合は、KMLファイルが必要になります。

初心者向けの簡単なチュートリアルをここで見ることができます。

于 2013-05-28T15:31:05.220 に答える