Skip to content

Commit d74757c

Browse files
authored
fix: fixed InfoWindow creation in KmlParser (#1624)
* fix_ fixed InfoWindow creation in KmlParser * fix: changed if structure * fix: no InfoWindow when the title is null * fix: minor chore
1 parent c4eef64 commit d74757c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

library/src/main/java/com/google/maps/android/data/Renderer.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,23 +1145,33 @@ private void setMarkerInfoWindow(KmlStyle style, Marker marker,
11451145

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

1153-
public View getInfoWindow(@NonNull Marker arg0) {
1153+
public View getInfoWindow(@NonNull Marker marker) {
11541154
return null;
11551155
}
11561156

1157-
public View getInfoContents(@NonNull Marker arg0) {
1157+
@Override
1158+
public View getInfoContents(@NonNull Marker marker) {
1159+
String title = marker.getTitle();
1160+
if (title == null) {
1161+
return null;
1162+
}
1163+
11581164
View view = LayoutInflater.from(mContext).inflate(R.layout.amu_info_window, null);
11591165
TextView infoWindowText = view.findViewById(R.id.window);
1160-
if (arg0.getSnippet() != null) {
1161-
infoWindowText.setText(Html.fromHtml(arg0.getTitle() + "<br>" + arg0.getSnippet()));
1162-
} else {
1163-
infoWindowText.setText(Html.fromHtml(arg0.getTitle()));
1166+
1167+
StringBuilder infoText = new StringBuilder(title);
1168+
1169+
String snippet = marker.getSnippet();
1170+
if (snippet != null) {
1171+
infoText.append("<br>").append(snippet);
11641172
}
1173+
infoWindowText.setText(Html.fromHtml(infoText.toString()));
1174+
11651175
return view;
11661176
}
11671177
});

0 commit comments

Comments
 (0)