2016-11-29 7 views
1

Googleでカスタムマーカーオプションを作成できますか?Googleマップのカスタムマーカーオプション

カスタムMarkerOptionsを使用して、enter image description hereというContainng Nameのようなダイアログボックスにイメージを表示し、その中に2つのイメージを入れたいとします。デフォルトMarkerOptionで

<ImageView 
    android:id="@+id/badge" 
    android:layout_width="18dp" 
    android:layout_height="wrap_content" 
    android:layout_marginRight="5dp" 
    android:src="@drawable/image_2" 
    android:adjustViewBounds="true"></ImageView> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="20dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:ellipsize="end" 
     android:text="harish" 
     android:singleLine="true" 
     android:textColor="#ff000000" 
     android:textSize="7dp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/snippet" 
     android:layout_width="10dp" 
     android:layout_height="10dp" 
     android:ellipsize="end" 
     android:src="@drawable/icon_location2" 
     android:singleLine="true" 
     android:textColor="#ff7f7f7f" 
     android:textSize="14dp" /> 
</LinearLayout> 

私は唯一のタイトル、スニペットは、このようなダイアログボックスに取得することができます。

public void addMarkersToMap() { 
    mArun = mMap.addMarker(new MarkerOptions() 
      .position(ARUN) 
      .title("Arun") 
      .snippet("Match stat:") 
      .icon(BitmapDescriptorFactory.defaultMarker 
       (BitmapDescriptorFactory.HUE_AZURE))); 

enter image description here

いくつかの提案で私を助けて。

+0

これは私の場合に役立ちました! http://androidfreakers.blogspot.com/2013/08/display-custom-info-window-with.html ありがとう –

答えて

2

クラスのsetInfoWindowAdapterメソッドを使用する必要があります。

GoogleMap mMap;//You have to initialise it. 

mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { 
      @Override 
      public View getInfoWindow(Marker marker) { 
       return null; 
      } 

      @Override 
      public View getInfoContents(Marker marker) { 
       /* 
       Here you will inflate the custom layout that you want to use for marker. I have inflate the custom view according to my requirements. 
       */ 
       View v = getLayoutInflater().inflate(R.layout.custom_marker_info_window, null); 
       TextView textView = (TextView) v.findViewById(R.id.text); 
       textView.setSelected(true); 
       textView.setText(poiPlayerData.getName()); 
       return v; 
      } 
     });