0

I have created a custom infoWindow for Google Map.

here is the Layout xml file

 <?xml version="1.0" encoding="utf-8"?>
 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:columnCount="2"
  android:rowCount="2"
  android:orientation="vertical">

    <TextView
        android:id="@+id/title"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        android:textStyle="bold"
        android:layout_row="0"
        android:layout_column="1"
        android:textColor="@color/DarkerGreen"
        android:textAlignment="center"
        android:layout_width="250dp" />

    <TextView
        android:id="@+id/snippet"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        android:layout_row="1"
        android:layout_column="1"
        android:textColor="@color/DarkerGreen"
        android:textAlignment="center"
        android:layout_width="250dp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:adjustViewBounds="true"
        android:src="@drawable/info_logo"
        android:layout_rowSpan="2"
        android:layout_row="0"
        android:layout_column="0"
        android:layout_marginEnd="5dp"
        android:contentDescription="@string/marker_icon_desc" />
 </GridLayout>

and here is my infowindow Class

class MyInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

    private final View myContentsView;

    MyInfoWindowAdapter() {
        myContentsView = getLayoutInflater().inflate(R.layout.map_info_content, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        return null;
    }

    @Override
    public View getInfoContents(Marker marker) {

        TextView tvTitle = ((TextView) myContentsView.findViewById(R.id.title));
        tvTitle.setText(marker.getTitle());
        TextView tvSnippet = ((TextView) myContentsView.findViewById(R.id.snippet));
        tvSnippet.setText(marker.getSnippet());

        return myContentsView;
    }
}

I want to add the route button and the google map button on the marker infoWindow itself. By default it appears at the lower right corner of the screen. But I also want it to appear inside of infowindow as well. I am new in android development and this is my first application, I tried a lot but couldn't succeed. Thanks in advance for your help and time. Let me know if I missed any information.


Edit: My appologies for not have good English. I actually want to implement the same behaviour as clicking the routing button, the problem is how and what parameters to be passed on the button click event so that it behaves in the same way as clicking the default routing button. i.e. it goes to the google map site and should the route between marker location and my current location.

Genutek
  • 387
  • 1
  • 5
  • 11
  • Unfortunately, this is not possible. – Daniel Nugent Jan 11 '17 at 19:33
  • See here as well: http://stackoverflow.com/questions/25058165/android-custom-info-window-google-map-v2-onclick-button – Daniel Nugent Jan 11 '17 at 19:34
  • Thank for your reply. Actual Issue is providing proper parameter to the button click event, so that it behaves in the same way as clicking the default routing button. i.e. go to the google routing and show route from selected marker co-ordinates to my current location. – Genutek Jan 11 '17 at 20:21
  • 1
    You can easily map each Marker to a LatLng. See here: http://stackoverflow.com/questions/30601892/android-google-maps-marker-infowindow-open-different-activities In your case you would use `HashMap` – Daniel Nugent Jan 11 '17 at 20:34

0 Answers0