I am trying to display some information when the user clicks on a marker using the snippet of Marker
class. As far as I know, the problem is that it can be only 1 line long, so I can't add a new line to make the information clearer. Is there any way to display more than one single line?
I'm using default MapActivity
and googleMap API V2
Thank you in advance for your patience and consideration.
Asked
Active
Viewed 70 times
-1

Eminent Emperor Penguin
- 835
- 1
- 7
- 21
-
You can create custom info window and make like this mMap.setInfoWindowAdapter(customInfoWindow); – Vadim Eksler Dec 03 '18 at 08:56
-
@VadimEksler could you please be more precise? What do you mean by "custom info window"? Could you please add some code? – Eminent Emperor Penguin Dec 03 '18 at 08:59
-
look at my answer – Vadim Eksler Dec 03 '18 at 09:00
1 Answers
1
You can create custom info window. Take a look this dock https://developers.google.com/maps/documentation/android-sdk/infowindows#custom_info_windows
Adapter example:
public class CustomInfoWindow implements GoogleMap.InfoWindowAdapter {
Context context;
LayoutInflater inflater;
public CustomInfoWindow(Context context) {
this.context = context;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
@Override
public View getInfoWindow(Marker marker) {
inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// R.layout.custom_info_window is a layout
// res/layout folder. You can provide your own
View v = inflater.inflate(R.layout.custom_info_window, null);
TextView title = (TextView) v.findViewById(R.id.info_window_title);
TextView subtitle = (TextView) v.findViewById(R.id.info_window_subtitle);
title.setText(marker.getTitle());
subtitle.setText(marker.getSnippet());
return v;
}
}
And for use it you need to make:
map.setInfoWindowAdapter(new CustomInfoWindow(context));

Vadim Eksler
- 865
- 9
- 24
-
-
for two buttons you can use this https://stackoverflow.com/questions/14123243/google-maps-android-api-v2-interactive-infowindow-like-in-original-android-go/15040761#15040761 – Vadim Eksler Dec 03 '18 at 09:07
-
1