0

I have cluster google map with markers, and now when i click marker info window is opened. But i want change info window position to down and if in one place there are many things i want display a list in horizontal recycler view , and after when i click to map it should dissapear.

I Also add that now i have slide tab and in one tab i have google maps.

So it should looks like this:

enter image description here

Some code: This is activity for slide tabs:

public class SlideTabsActivity extends AppCompatActivity {

private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_slide_tabs);
    if(SearchObjectList.getSearchObjectList().isEmpty()){
        Toast.makeText(getApplicationContext(), "Nic nie zostalo wybrane, wroc do SLideTabsActivity class aby zrobic jakas operacje gdy pusta lista",Toast.LENGTH_LONG).show();
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);

    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));

}
public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        // getItem is called to instantiate the fragment for the given page.
        switch (position){
            case 0:
                FirstSlideTab firstSlideTab = new FirstSlideTab();
                return  firstSlideTab;
            case 1:
                SecondSlideTab secondSlideTab = new SecondSlideTab();
                return  secondSlideTab;
            case 2:
                ThirdSlideTab thirdSlideTab = new ThirdSlideTab();
                return thirdSlideTab;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        // Show 3 total pages.
        return 3;
    }
    @Override
    public CharSequence getPageTitle(int position) {
        switch (position){
            case 0:
                return "FIRST";
            case 1:
                return "SECOND";
            case 2:
                return "THIRD";
        }
        return  null;
    }
}

} In SecondSlideTab i have google map and class that is responsible for cluster in google map. This is xml file of SecondSlideTab:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="kamilmilik.flatsearch.showresultactivity.SlideTabsActivity">

<com.google.android.gms.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<ProgressBar
    android:id="@+id/progress"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    app:layout_constraintBottom_toBottomOf="@+id/mapView"
    app:layout_constraintEnd_toEndOf="@+id/mapView"
    app:layout_constraintStart_toStartOf="@+id/mapView"
    app:layout_constraintTop_toTopOf="@+id/mapView" />

<FrameLayout
    android:id="@+id/fram_info_content"
    android:layout_width="match_parent"
    android:clickable="true"
    android:layout_height="150dp"
    app:layout_constraintBottom_toBottomOf="@+id/mapView"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
     />

What I should add to get this info window? I need fragment or something else? How add it to my slide tabs and my google map view ?

grap
  • 23
  • 1
  • 6

1 Answers1

0

I suggest you create a RecyclerView and align it to parent bottom. Then add a OnMarkerClickListener to you google map marker. When a click is detected you can feed your RecyclerView adapter with the content associated with that marker.

This link heps you understand how the mapview can be implemented. How to use MapView in android using google map V2?

The marker is created in onMapReady(GoogleMap gm) callback.

To understand how to create a marker please read this: https://developers.google.com/maps/documentation/android-api/marker

You can toggle the recycler view visibility when you click the marker.

Victor Gomes
  • 129
  • 8
  • Okey, so i must add recyclerView as fragment to my my layout where i have google map? If yes , how can i hide this recycler view when i click to map? Is any method ? – grap Dec 13 '17 at 17:37
  • You don't need it to be a fragment. You can hide the recycler when detecting a click in the map for example. Like this: https://stackoverflow.com/a/22473883/2062034 – Victor Gomes Dec 14 '17 at 16:42