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

MapView Overlay inside Dialog #6101

Closed
michaelblind opened this issue Aug 21, 2016 · 5 comments
Closed

MapView Overlay inside Dialog #6101

michaelblind opened this issue Aug 21, 2016 · 5 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@michaelblind
Copy link

michaelblind commented Aug 21, 2016

Platform: Android
Mapbox SDK version: 4.2.0-beta1

Steps to trigger behavior

Using MapView inside Dialog:

  1. Define MapView in layout file
  2. Inflate layout file in onCreateDialog()

Expected behavior

Normal looking Map (Behaviour in version 4.1.1)

Actual behavior

Dark Filter over Map, Map looks as if in Background

screenshot_20160821-025618

Theme: Custom Theme based on Light / Bug exists also with standard theme Light

@tobrun
Copy link
Member

tobrun commented Aug 22, 2016

Thank you for reaching out, this "filter" is coming from the dialog theme. Our maps are displayed using a SurfaceView, copying from the Android docs about SurfaceView:

Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen. The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it.

After googling, I can see that there are some hacks to work around this issue, couldn't find a clean solution to post here though but you could try running with some of suggestions given on StackOverflow. Let us know if something worked out for you.

For this use-case, I would suggest using our static image api. I seems the image in OP is used to display a non interactive map. An example can be found here: https://www.mapbox.com/api-documentation/?language=Java#static

I hope above information get's you on the right track, reach out if you have any other questions.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Aug 22, 2016
@michaelblind
Copy link
Author

Thank you for the quick reply, unfortunately, I am using the MapView as a 'LocationPicker' so a static map will not suffice.

I had already looked at possible Solutions concerning SurfaceView in Dialogs, my main problem is that I cannot treat the MapView as a SurfaceView, so I can't call the necessary methods. Upon looking at the class inheritance it appears that MapView extends FrameLayout...

My question is whether there is any way for me to access the SurfaceView you are using to display your maps? That way I would most likely be able to fix the problem for me

@tobrun
Copy link
Member

tobrun commented Aug 22, 2016

You can get a reference to the following SurfaceView found in mapview_internal.xml:

 <SurfaceView
        android:id="@+id/surfaceView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

by calling:

SurfaceView surfaceView = (SurfaceView) mapView.findViewById(R.id.surfaceView);

@tobrun
Copy link
Member

tobrun commented Aug 25, 2016

@michaelblind I have been trying this out myself and hitting the same issue you are mentioning. I would advice using an Activity with transparent background instead. This will allows you to create dialog effect. While I find showing a MapView in an Android SDK dialog a very useful feature. It's not in our list of top features to implement.

@tobrun
Copy link
Member

tobrun commented Dec 21, 2016

We now has an example in our test app using a texture view as workaround, see here.

This results in showing the map correctly:

device-2016-12-21-095230

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

2 participants