So my application requires me to create a route for a certain bus. I have accomplished this and have created a custom info window for the marker. Now, I was asked to add a featu
Got it. So to get multiple Info windows, I had to get the marker ids corresponding to the markers. So I created a ArrayList that takes in the "id" of the marker.
ArrayList<String> markerPlaces = new ArrayList<>();
I then populated it as I add the markers to the map:
Marker marker = map.addMarker(new MarkerOptions().position(position)
.title(venuesfound.get(i).getName())
.snippet("\nOpen: " + venuesfound.get(i).getOpenNow()
+ "\n(" + venuesfound.get(i).getCategory() + ")")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.measle_blue)));
markerPlaces.add(marker.getId());
Then on the InfoAdapter, I just added a condition that if the marker id is in the ArrayList that I created, then put in a different inflater.
public class InfoAdapter implements GoogleMap.InfoWindowAdapter {
LayoutInflater inflater = null;
private TextView textViewstopName;
private TextView arrivalTime;
public InfoAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
@Override
public View getInfoWindow(Marker marker) {
if (marker != null) {
if(markerPlaces.containsKey(marker.getId())) {
... //Add new inflater here.
} //checks if the marker is part of the Position marker or POI marker.
else{
View v = inflater.inflate(R.layout.businfo_layout, null);
textViewstopName = (TextView) v.findViewById(R.id.businfo);
textViewstopName.setText(marker.getTitle());
arrivalTime = (TextView) v.findViewById(R.id.arrivalinfo);
arrivalTime.setText(marker.getSnippet());
return (v);
}
}
return null;
}
@Override
public View getInfoContents(Marker marker) {
return (null);
}
}
Thank you all for the help! It certainly got me thinking!