Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Info Window translated out of view when MapView embedded in PagerAdapter #10288

Closed
jimjeffers opened this issue Oct 25, 2017 · 1 comment
Closed
Labels
Android Mapbox Maps SDK for Android

Comments

@jimjeffers
Copy link

Platform:
Android

Mapbox SDK version:
mapbox-android-sdk:5.2.0-beta.2

Steps to trigger behavior

  1. Have a PageAdapter that displays a map view as page 2 of 3.
  2. Add markers with titles and snippets to the map.
  3. Attempt to display an info window by tapping the annotation.

Expected behavior

The default info window should appear above the marker annotation which was just tapped.

Actual behavior

The info window appears just outside of the scroll view. As if the offset from the view pager is being applied to the info window but not the annotations. The annotations/markers show up in the right spot but the info window is translated. This does NOT happen if the map view is instantiated as the first view within the page adapter in my application. I've attached a screenshot illustrating the effect.

infowindowoffset

Here is how the map is instantiated in the pager adapter:

        @Override
        public Object instantiateItem(ViewGroup container, int position) {

            ViewPager.LayoutParams params = new ViewPager.LayoutParams();
            params.width = ViewPager.LayoutParams.MATCH_PARENT;
            params.height = ViewPager.LayoutParams.MATCH_PARENT;

            if (position == 1 && showMap) {
                return instantiateMap(container, params);
            }
           //...
     }

     private Object instantiateMap(ViewGroup container, ViewPager.LayoutParams params) {
            mapView = new MapView(getActivity());
            mapView.setLayoutParams(params);
            mapView.onCreate(savedInstanceState);
            mapView.setStyleUrl(competition.getMapBoxStyleURL());
            setMapDetails(); // Cycles through data and adds annotations to map.
            container.addView(mapView);
            return mapView;
        }
@fabian-guerra fabian-guerra added the Android Mapbox Maps SDK for Android label Oct 26, 2017
@tobrun
Copy link
Member

tobrun commented Sep 19, 2018

This is going to be fixed with moving InfoWindow to a symbol layer approach in #10449. Closing this issue in favor of that one.

@tobrun tobrun closed this as completed Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants