2016-11-29 5 views
1

Можем ли мы создать пользовательские маркеры в Google?Пользовательские параметры маркера в google map

Я хочу использовать Custom MarkerOptions для отображения изображения в диалоговом окне, например enter image description here Containng Имя в качестве заголовка и два изображения внутри него.

<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> 

С умолчанию MarkerOption я могу получить только название, Snippet в диалоговом окне, как это:

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.

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; 
      } 
     });