Question

I have different Markers based on their different information to show in custom infowindow. For that I have use different class for each infowindow content.

I can see different Markers in my map. But I tap on them, only the lastly built marker's information is showing. Basically the infowindow content is same. Also I noted that when I tap, it does not call the relevent infowindow instead its calling lastly created infowindow's getInfoContents(Marker arg0). But I receive the correct marker inside to getInfoContents(Marker arg0) to the lastly added marker.

We can have only one infowindow implementation for all the markers in the map? And based on the marker identification should I implement the different contents?

Marker type A implementation

 public class MapGoogleOverlayV2 {

    private ViewGroup infoWindow;

    public boolean onTap() {


    infoWindow  = (ViewGroup)((Activity)mContext).getLayoutInflater().inflate(R.layout.info_window_layout, null);


    /*Custom info window implementation is below */
    googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {

            return null;
        }

        @Override
        public View getInfoContents(Marker arg0) {

            // set title
            ((TextView)infoWindow.findViewById(R.id.title)).setText("Test text");

            // set freeText
            ((TextView)infoWindow.findViewById(R.id.text)).setText(Long.toString("1"));


              return infoWindow;

        }
    });
   }
}

Marker B implemented in another class with different info. and I am calling onTap()

I create two markers with different information by calling their own implementation and display that in map.

only problem is they both show same information which is last marker's information.

Was it helpful?

Solution

Setters (and GoogleMap.setInfoWindowAdapter seems to be a setter) replace what was there before.

If you call onTap in both classes, only the last InfoWindowAdapter survives.

Instead you need to set only one InfoWindowAdapter and decide for which Marker you need to show info window based on getInfoContents parameter (Marker arg0).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top