androidhere-apiinfobubble

Android Here-API :How to add buttons to a Here maps infobubble


Is it possible to add a button to a Here maps info-bubble. I checked Android here maps api but did not find any thing useful. Just wondering if any one has tried this before?

Thanks


Solution

  • you should use InfoBubbleAdapter to set bubble layout :

    Map hMap.setInfoBubbleAdapter(new Map.InfoBubbleAdapter() {
                @Override
                public View getInfoBubbleContents(MapMarker mapMarker) {
                    return null;
                }
    
                @Override
                public View getInfoBubble(final MapMarker mapMarker) {
                    View bubble;
                    bubble = LayoutInflater.from(getActivity()).inflate(R.layout.tooltip_cluster, container, false);
                    Button btn = (Button) bubble.findViewById(R.id.btnBubble);
                    return bubble;
                }
            });
    

    and define button in your layout

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:background="#00f">
    
        <EditText
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:gravity="center"
            android:hint="Hello World !"
            android:textColor="@android:color/white"
            android:background="#c0392b"/>
    
        <Button
            android:layout_below="@+id/btnBubble"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="click ME !"/>
    
    </RelativeLayout>