2013-11-21 5 views
0

마커 (1,2,3 ...)에 숫자가있는 사용자 정의 안드로이드 마커를 만들고 InfoWindow에서 펼치기 버튼을 사용하여 어떻게 만들 수 있습니까? 내가 같이 내가 InfoWindow는 약안드로이드 v2 맵의 맞춤 마커

//add marker to Map 
mMap.addMarker(new MarkerOptions().position(USER_POSITION) 
    .icon(BitmapDescriptorFactory.fromBitmap(bmp))//my image here 
    // Specifies the anchor to be at a particular point in the marker image. 
    .anchor(0.5f, 1)); 

그러나 같은 .icon으로 해결할 수있는 첫 번째 질문을 이해? 큰 InfoWindow를 팝업하는 버튼을 추가하는 방법?

답변

2

이 simiple입니다 이런 식으로 할 ...

googleMap.setInfoWindowAdapter(new InfoWindowAdapter() { 

      // Use default InfoWindow frame 
      @Override 
      public View getInfoWindow(Marker marker) {    
       return null; 
      }   

      // Defines the contents of the InfoWindow 
      @Override 
      public View getInfoContents(Marker marker) { 

       // Getting view from the layout file info_window_layout 
       View v = getLayoutInflater().inflate(R.layout.info_window_layout, null); 

       // Getting reference to the TextView to set title 
       TextView note = (TextView) v.findViewById(R.id.note); 

       note.setText(marker.getTitle()); 

       // Returning the view containing InfoWindow contents 
       return v; 

      } 

     }); 

그냥 당신이 GoogleMap으로를 사용하는 클래스의 코드 위에 추가합니다. R.layout.info_window_layout은 infowindow를 대신 할 뷰를 보여주는 커스텀 레이아웃입니다. 방금 textview를 추가했습니다. 여기에 추가보기를 추가하여 샘플 스냅처럼 만들 수 있습니다. 내 info_window_layout는

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 

     <TextView 
     android:id="@+id/note" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 
+0

감사합니다,하지만 난으로 MapFragment에 모든 것을 할 경우,하지의 활동 니스 – onCreate

+0

에, 나는 acticity 컨텍스트 및 모든 문제 아래로 무엇을 사용. 질문이 하나 더 있습니다. InfoWindow를 클릭 할 수있게 만드는 방법을 클릭하고 자세한 정보 (다른 레이아웃)로 클릭하십시오. – onCreate

+0

@onCreate StackOverflow에 오신 것을 환영합니다. 댓글은 질문에 좋지 않지만 답변은 다음과 같습니다. http://stackoverflow.com/questions/14123243/google-maps-api-v2-custom-infowindow-like-in-original-android-google-maps –