0

デフォルトのGoogleマップマーカーは赤いピンです。インテントを介してデフォルトのマーカー画像をカスタム画像に置き換えることは可能ですか?

編集:これは、外部マップアプリを起動するためにgeouriインテントを送信する場合です。MapActivityサブクラスを使用してアプリ内でそれを行う場合はそうではありません。

4

2 に答える 2

0

はい。私はあなたの質問が正しくあることを願っています:あなたはオーバーレイアイテムを通してそれをすることができます。Google自体からこの例を確認してください。ドローアブルを指定することで、任意のマーカーをカスタマイズできます。

于 2012-12-05T12:39:39.127 に答える
0

配列内の画像位置を含む整数を送信できます。

Intent i = new Intent (yourClass.this, MapActivity.class)
i.putExtra("pinPosition",2);
startActivity(i);

そしてあなたの地図活動において:

 public class MyMapActivity extends MapActivity {
    private int drawables[] = { R.drawable.pin1, R.drawable.pin2, R.drawable.tutorial_pin3 };
    int position;

    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            if (getIntent().getSerializableExtra("pinPosition")!=null) {
        position = getIntent().getSerializableExtra("pinPosition");
            }

            setContentView(R.layout.publish_map_activity);
            map = (MapView) findViewById(R.id.mapview);
            ImageView pin = (ImageView) findViewById(R.id.drag);
            pin.setImageResource(drawables[position]);
    ....

    }

    }

同様のGoogleコードを使用する場合、xmlは次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="@string/googlemaps_key"
        android:clickable="true" />

    <ImageView
        android:id="@+id/drag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/contentDescription"
        android:src="@drawable/mapitempng"
        android:visibility="gone" />
</RelativeLayout>
于 2012-12-05T12:53:01.463 に答える