OmAr Hesham
OmAr Hesham

Reputation: 153

Show multiple marker titles on Map

I successfully added multiple markers on the map. Using the showInfoWindow only shows the title of the last added marker. so is there a way to show all the markers' title at once? Thanks :)

Upvotes: 1

Views: 3103

Answers (3)

Shikhar
Shikhar

Reputation: 303

LinearLayout tv = (LinearLayout) this.getLayoutInflater().inflate(R.layout.marker_dialog, null, false);
tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());

tv.setDrawingCacheEnabled(true);
tv.buildDrawingCache();
Bitmap bm = tv.getDrawingCache();

LatLng latLng = new LatLng(latitudemy, longitudemy);

BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bm);

BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher);
map.addMarker(new MarkerOptions().position(new LatLng(latitudemy, longitudemy)).title("origin").snippet("Srivastava").icon(icon));
// Showing the current location in Google Map
map.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("destination").snippet("Srivastava").icon(icon));

Upvotes: 2

MaciejGórski
MaciejGórski

Reputation: 22232

This is not possible to directly show all info windows.

I'd suggest to use custom marker icon and Canvas to draw your text above the marker which could look like info window.

Upvotes: 2

Emil Adz
Emil Adz

Reputation: 41099

AFAIK this is the functionality of Google Map API V2, only one InfoWindow is shown at any given time.

Upvotes: 0

Related Questions