mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Jetpack compose map not showing - map foreground-color is how background themes.xml is set

Open tilenpinta opened this issue 3 years ago • 1 comments

Environment

  • Android OS version: 11.0.7.1.HD65BA
  • Devices affected: any
  • Maps SDK Version: 10.6.0-rc.1

When i open a screen of mapbox i couldn't see map.

My code:

AndroidView(
      factory = { MapView(context) },
      modifier = Modifier.fillMaxSize()
  ) { mapView ->
      mapView
          .getMapboxMap().apply {
              loadStyleUri(Style.MAPBOX_STREETS)
              addOnStyleLoadedListener {
                  setCamera(
                      CameraOptions.Builder()
                          .center(Point.fromLngLat(46.0, 16.0))
                          .zoom(2.0)
                          .build()
                  )
              }
          }
  }

Later on I discovered the issue were in themes.xml

  • if I set it like that
    <style name="Theme.AppCompat.MyTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:background">@android:color/holo_red_light</item>
    </style>
  • but if i delete item background it shows correctly <style name="Theme.AppCompat.MyTheme" parent="Theme.AppCompat.DayNight.NoActionBar" />

tilenpinta avatar Jun 10 '22 13:06 tilenpinta

im having the same problem, did you manage to fix It?

ismai117 avatar Sep 13 '22 11:09 ismai117

There is a response here: https://stackoverflow.com/a/72574810/2457169 maybe it will help future ppl :)

carlosrivin avatar Oct 26 '22 15:10 carlosrivin

Closing this ticket but please feel free to reopen if you continue to experience this issue.

ZiZasaurus avatar Nov 11 '22 15:11 ZiZasaurus

Facing the same issue. Screenshot 2023-05-27 at 21 11 47 <style name="Theme.OpenMapsTest" parent="android:Theme.Material.Light.NoActionBar">

`

implementation 'com.mapbox.maps:android:10.13.0'

`

pphilipp avatar May 27 '23 19:05 pphilipp

AndroidView( factory = { MapView(context) }, modifier = Modifier.fillMaxHeight().fillMaxWidth(), update = { mapView ->

                val mapboxMap = mapView.getMapboxMap()

                mapboxMap.apply {
                    loadStyleUri(Style.LIGHT) { style ->

                    }

                    addOnStyleLoadedListener {
                        setCamera(
                            CameraOptions.Builder()
                                .center(
                                    Point.fromLngLat(
                                        100.43785206937319,
                                        5.963021810066703
                                    )
                                ) //100.43815946478934 5.959938586825725

// .center(Point.fromLngLat(55.3089185, 25.255377)) .zoom(15.0) .build()

                        )
                    }


                }

                mapboxMap.setRenderCacheOptions(RenderCacheOptions.Builder().setLargeSize().build())


            }
        )
        
        
        implementation 'com.mapbox.maps:android:10.13.0'
        try this one, it work on my side. but im stuck here, cannot add button to change layer on runtime.

zahid-latconnect avatar May 30 '23 01:05 zahid-latconnect