Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions library/src/main/java/com/google/maps/android/data/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1145,23 +1145,33 @@ private void setMarkerInfoWindow(KmlStyle style, Marker marker,

/**
* Creates a new InfoWindowAdapter and sets text if marker snippet or title is set. This allows
* the info window to have custom HTML.
* the info window to have custom HTML. If the marker has no title, the InfoWindow is deactivated.
*/
private void createInfoWindow() {
mMarkers.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

public View getInfoWindow(@NonNull Marker arg0) {
public View getInfoWindow(@NonNull Marker marker) {
return null;
}

public View getInfoContents(@NonNull Marker arg0) {
@Override
public View getInfoContents(@NonNull Marker marker) {
Copy link
Contributor

@dkhawk dkhawk Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly cleaner:

        @Override
        public View getInfoContents(@NonNull Marker marker) {
            String title = marker.getTitle();
            if (title == null) {
                return null;
            }

            View view = LayoutInflater.from(mContext).inflate(R.layout.amu_info_window, null);
            TextView infoWindowText = view.findViewById(R.id.window);

            StringBuilder infoText = new StringBuilder(title);
            
            String snippet = marker.getSnippet();
            if (snippet != null) {
                infoText.append("<br>").append(snippet);
            }
            infoWindowText.setText(Html.fromHtml(infoText.toString()));

            return view;
        }

String title = marker.getTitle();
if (title == null) {
return null;
}

View view = LayoutInflater.from(mContext).inflate(R.layout.amu_info_window, null);
TextView infoWindowText = view.findViewById(R.id.window);
if (arg0.getSnippet() != null) {
infoWindowText.setText(Html.fromHtml(arg0.getTitle() + "<br>" + arg0.getSnippet()));
} else {
infoWindowText.setText(Html.fromHtml(arg0.getTitle()));

StringBuilder infoText = new StringBuilder(title);

String snippet = marker.getSnippet();
if (snippet != null) {
infoText.append("<br>").append(snippet);
}
infoWindowText.setText(Html.fromHtml(infoText.toString()));

return view;
}
});
Expand Down