텐센트 맵은 여러 InfoWindow 문제를 보여줍니다.

1296 단어 텐센트 지도
방금 텐센트 지도 관련 프로젝트를 했지만 문서를 본 후에 오픈 플랫폼에서 여러 개의 InfoWindow를 표시하는 방법을 제시하지 않았고 텐센트 개발자에게 물었지만 답을 주지 않았다. 현재 많은 인터넷 자료를 보고 이 기능을 스스로 만들어 냈다.
아래 위 코드:
public class Bean {
    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}

List data = new ArrayList<>();
/**
 *          Marker
 */
for (int i = 0; i < data.size(); i++) {

    Bean bean  =data.get(i);
    //     
    LatLng latLng = new LatLng(latitude, longitude);
    final Marker marker = tencentMap.addMarker(new MarkerOptions());//   marker 
    marker.setPosition(latLng);//   
    marker.setTag(i);

    //   icon ,    fromView           
    marker.setIcon(BitmapDescriptorFactory.fromView(getCustomerView(Bean, size)));

    marker.setAnchor(0.5f, 1f);//      
}
/**
 *            
 */
public View getCustomerView(Bean bean,int size) {
    View view = View.inflate(getContext(), R.layout.layout_marker, null);
    TextView tv1 = (TextView) view.findViewById(R.id.tv_1);
    ImageView ivLocation = (ImageView) view.findViewById(R.id.iv_location);

    tv1.setText(bean.getContent());
    ivLocation.setImageResource(R.drawable.main_map_location1);
    return view;
}

좋은 웹페이지 즐겨찾기