1

mapView クラスと StoreFinder クラスがあります。ジオポイント値の経度と緯度を保持する AlertDialog にあるボタンを押すことができるようにしたいと考えています。MapView に経度と緯度の値の位置を表示したい。

単純:

ALERTDIALOGの経度と緯度でボタンを押します - > MapViewの表示位置。

どうすればこれを行うことができますか?

十分な時間をありがとうございました。

コード:

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.storefinder_bars);

    sirius();
}

public void sirius() {
    ImageButton hoursButton = (ImageButton) findViewById(R.id.hours);
    ImageButton addressButton = (ImageButton) findViewById(R.id.address);
    //ImageButton phoneButton = (ImageButton) findViewById(R.id.phone);


    final AlertDialog.Builder siriushours = new AlertDialog.Builder(this);
    hoursButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            siriushours.setTitle("Opening Hours");
            siriushours.setMessage(

                       "\n---Monday---\n" +        "CLOSED" 
                     + "\n\n---Tuesday---\n" +     "CLOSED" 
                     + "\n\n---Wednesday---\n" +   "22:00 - 3:00" 
                     + "\n\n---Thursday---\n" +    "CLOSED" 
                     + "\n\n---Friday---\n" +      "22:00 - 3:00"
                     + "\n\n---Saturday---\n" +    "22:00 - 3:00"
                     + "\n\n---Sunday---\n" +      "CLOSED");

            siriushours.setPositiveButton("OK",
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {
                            dialog.dismiss();
                        }

                    });

            siriushours.show();
        }
    });

    //ADDRESS
    final AlertDialog.Builder siriusadd = new AlertDialog.Builder(this);
    addressButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            siriusadd.setTitle("Address");
            siriusadd.setMessage(

                    "33 Belvoir Street, Leicester , LE1 6SL");



            siriusadd.setPositiveButton("Show On Map",
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {




                        }

                    });

            siriusadd.setNegativeButton("Route",
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {
                            Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                                    Uri.parse("http://maps.google.com/maps?daddr="+52.63274+","+-1.13145));
                                    startActivity(intent);
                        }

                    });


            siriusadd.show();
        }
    });


}

ポジティブ ボタンをここに配置したい: "siriusadd.setPositiveButton("Show On Map", ") これにより、AlertDialog から MapView の地理座標にジャンプできるようになります。そうでない場合は、バルーンのアイテム化されたレイアウトがあり、マーカーが代わりにそこにジャンプしてくれればいいのですが、ジオポイントでも構いません。

すべての支援に乾杯。

4

2 に答える 2

1

MapController目的のジオポイントにアニメーション化するために使用します。MapControllerあなたのインスタンス化MapView

private MapController mc;
mc = mapView.getController();

ボタンに設定されたダイアログの初期化後onClickListener(ここではポジティブ ボタンの例を示します。

dialog.setPositiveButton(mContext.getString(R.string.photo), new DialogInterface.OnClickListener() { 

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub          
                mc.animateTo(geoPoint);
            }

        });
于 2012-04-22T14:03:08.187 に答える
0

インテントの呼び出しに putExtra を使用するだけです。

siriusadd.setPositiveButton("Show On Map",
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog,
                            int which) {

                        Intent myIntent = new Intent(getApplicationContext(),
                            MyMapActivity.class);
                        myIntent.putExtra("id", anId);
                        // add any additional informations with other key values 
                        // (latitude or longitude)
                        startActivityForResult(myIntent, 0);

                    }

                });

マップ アクティビティの onResume メソッドでこれらの情報をマップ アクティビティに取得し、マップ ビューを適切に設定します。

@Override
protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    if (intent.getStringExtra("id") == null) {
        // your map logic goes here
    }

}
于 2012-04-22T17:56:19.557 に答える