どのように私は、これはGoogleマップ上のマーカーを表示するために得ることができますか?

マルク・Leese:

私は、座標やRSSフィードからのクリックでから収集したタイトルを渡そうとしていると私はGoogleが、それは私の問題は、マップ上に表示されている問題なく通過んデバッグからマップするにそれを渡したいです。ここで意図してonclickのは、次のとおりです。

       public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
            Intent in = new Intent(getApplicationContext(), MapsActivity.class);
            String georss = ((TextView) view.findViewById(R.id.georss)).getText().toString();
            String title = ((TextView) view.findViewById(R.id.title)).getText().toString();
            String[] latLng = georss.split(" ");
            double lat = Double.parseDouble(latLng[0]);
            double lng = Double.parseDouble(latLng[1]);;
            LatLng location = new LatLng(lat, lng);
            in.putExtra("location", location);
            in.putExtra("title", title);
            startActivity(in);
        }
    });

そして、ここで作成上のGoogleマップは次のとおりです。

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        Intent intent = getIntent();
        intent.getStringExtra("title");
        intent.getStringExtra("location");

私はちょうどあなたがそれをクリックしたときには、タイトルを見ることができるようにマーカーを表示する方法はありませんよ。

グリーンY.:
intent.getStringExtra("location");

位置パラメータはLatLang、ない文字列であるので、あなたが意図から位置を取得することはできません。別途緯度とLNGを送信する方が良いでしょうそれはそう。

...
in.putExtra("lat", lat);
in.putExtra("lng", lng);
startActivity(in);

...
Intent intent = getIntent();
double lat = intent.getDoubleExtra("lat", 0);
double lng = intent.getDoubleExtra("lng", 0);
...

[編集]

それとも、このようなLatLangデータを解析することができます。

...
in.putExtra("location", location);
startActivity(in);

...
Intent intent = getIntent();
LatLng location = (LatLng) intent.getExtras().get("location");
...

そのようにすることで、あなたは意図からオブジェクトデータを取得することができます。しかし、この場合には、あなたは、キーを確認する必要がありそうでない場所がnullにすることができます。ありがとうございました。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=365200&siteId=1