Reputation: 1872
I have multiple markers with its information on the map. By tapping on a particular marker it shows information. Below is the code for adding multiple markers:
for (int i = 0; i < list.size(); i++) {
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> hmPlace = list.get(i);
double lat = Double.parseDouble(hmPlace.get("lat"));
double lng = Double.parseDouble(hmPlace.get("lng"));
String name = hmPlace.get("place_name");
String vicinity = hmPlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(name + ":" + vicinity);
googleMap.addMarker(markerOptions);
}
My output is seen like this:
When I tap on a marker it is not displaying the full text. Instead of that it shows me some text and after some dots display.
Is there any method in Google Map V2 to show the full text? I already use the title()
method of the "MarkerOptions" class.
Upvotes: 3
Views: 3132
Reputation: 1872
Thanks for helping.But I solved my issue.
Just create one class which extends InfoWindowAdapter.
class MyInfoWindowAdapter implements InfoWindowAdapter {
private final View myContentsView;
private String name, vicinity;
public MyInfoWindowAdapter(String name, String vicinity) {
myContentsView = getLayoutInflater().inflate(
R.layout.custom_info_contents, null);
this.name = name;
this.vicinity = vicinity;
}
@Override
public View getInfoContents(Marker marker) {
TextView tvTitle = ((TextView) myContentsView
.findViewById(R.id.title));
tvTitle.setText(name);
TextView tvSnippet = ((TextView) myContentsView
.findViewById(R.id.snippet));
tvSnippet.setText(vicinity);
return myContentsView;
}
@Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
}
And use setInfoWindowAdapter() method of GoogleMap.
googleMap.setInfoWindowAdapter(new MyInfoWindowAdapter(name,
vicinity));
Upvotes: 4
Reputation: 347
Try following code
MarkerOptions options = new MarkerOptions();
options.position(origin);
options.title("Current Location");
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
mMap.addMarker(options);
Hope this will help you
Upvotes: -1