mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.37k stars 1.33k forks source link

Android Mapbox Mapview shows white screen before rendering maps #16367

Closed bssandeshbs closed 4 years ago

bssandeshbs commented 4 years ago

Mapbox Mapview shows a white screen flash before the Mapview is rendered. The flash stays for like 500ms after which the map is displayed. I am adding Mapview dynamically to my FrameLayout((addView()) at run time. Below is the code snippet. Please help !

Is there any property that needs to be specifically set for mapview

Platform: Android Mapbox SDK version: 9.0.0

Steps to trigger behavior

  1. Create a new Mapbox() Instance
  2. Add it to a layout dynamically
  3. Call Mapbox.getAsync() API
  4. white screen flash before mapview is displayed
private fun initializeMapBoxMap() {
    val mapView = MapView(context) // create new mapview 
    innerLayout.addView(mapView) // add mapView to the FrameLayout
    mapView.getMapAsync { mapboxMap ->
           // white screen shown at this point for 500 ms 
           mapboxMap.setStyle(Style.DARK) {
              // white screen gone after this point
           }
    }
}

Expected behavior : white screen should not be shown before rendering maps

Actual behavior : white screen shown before rendering the maps

Mapbox

tobrun commented 4 years ago

you can change the color to another with:

mapboxMapOptions.foregroundLoadColor(int color)

we try to mask that the glsurfaceview has loaded but we don't have any content to render as we are still loading the style definition. instead of loading resources, having them offline will also improve the UX.