MAP上的多个信息窗口

时间:2013-05-05 04:08:22

标签: android api google-maps infowindow

我正在开发一个主要使用Google MAP API的Android应用程序。 目前,Google MAP api仅允许标记上的单个信息窗口。我需要在地图上的所有标记上放置文本或图像,并同时显示所有信息窗口。

有人知道我们该怎么办?

1 个答案:

答案 0 :(得分:0)

我想你可能得到了答案。因为我的回答对其他人有帮助。

您需要创建自己的InfoWindowAdapter以在infoWindow中显示多个信息。

setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

        // Use default InfoWindow frame 
        @Override 
        public View getInfoWindow(Marker arg0) {
            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 = getActivity().getLayoutInflater().inflate(R.layout.maps_infowindow, null);
            v.setLayoutParams(new LinearLayout.LayoutParams((int) (mapFragment.getView().getMeasuredWidth() * .9), LinearLayout.LayoutParams.WRAP_CONTENT));
            ((TextView) v.findViewById(R.id.title)).setText(marker.getTitle());
            ((TextView) v.findViewById(R.id.desc)).setText(marker.getSnippet());
            ImageView markerIcon = (ImageView) v.findViewById(R.id.imageView5);
            markerIcon.setImageResource(R.mipmap.back_vision_fade); 
            return v;

        }
    });