Multiple Info Windows in Android Maps API 2

In the docs it states:

Since there is only one info window shown at any one time, this
provider may choose to reuse views, or it may choose to create new
views on each method invocation.

So no you can’t do it with the regular infoviews but it isn’t too hard creating markers that act as infoviews.

Edit

I’d create a view in xml that you want to use as a marker/dialog. Something like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:orientation="vertical"
    android:background="@android:color/white"
    >
    <TextView
        android:text="test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <ImageView 
        android:src="https://stackoverflow.com/questions/15331983/@drawable/ic_launcher"
        android:layout_width="50dp"
        android:layout_height="50dp"/>
</LinearLayout>

Then I’d convert this view into a bitmap and use that bitmap as my marker:

        ImageView image = (ImageView) findViewById(R.id.main_image);

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

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

Leave a Comment