mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
478 stars 134 forks source link

layerPositionedContent renders layers in reverse order #2524

Open jeffbarge opened 1 day ago

jeffbarge commented 1 day ago

Environment

Observed behavior and steps to reproduce

When using a Composable function with more than 1 layer, and adding to the map via layerPositionedContent, the first layer added renders on top, which is backwards from when adding the same composable to the mapContent.

Example:

    @Composable
    private fun PolylineBase() {
        val lineSource = rememberGeoJsonSourceState {
            data = GeoJSONData(
                Feature.fromGeometry(
                    LineString.fromLngLats(
                listOf(
                    Point.fromLngLat(0.0, 0.0), Point.fromLngLat(1.0, 1.0))
            )))
        }

        LineLayer(sourceState = lineSource) {
            lineColor = ColorValue(
                Color(0xFF999999)
            )
            lineWidth = DoubleValue(12.0)
            lineBorderWidth = DoubleValue(2.0)
            lineBorderColor = ColorValue(Color(0xFF333333))
        }

        val geoJsonSource = rememberGeoJsonSourceState {
            data = GeoJSONData(Point.fromLngLat(0.0, 0.0))
        }

        SymbolLayer(
            sourceState = geoJsonSource
        ) {
            iconAnchor = IconAnchorValue.BOTTOM
            textField = FormattedValue("Hello Helsinki")
            textColor = ColorValue(Color.Red)
            textColorTransition = Transition(durationMillis = 1000)
            textSize = DoubleValue(20.0)
            textAllowOverlap = BooleanValue(true)
        }
    }

Note that the text from the SymbolLayer renders beneath the LineLayer, even though it was added last.

mapboxBorken

Expected behavior

The last Layer added should render on top. This is the behavior when adding layers to MapContent.

Notes / preliminary analysis

Additional links and references

jush commented 1 day ago

Thanks for the issue. We'll let you know once we've fixed it.

(internal ticket: MAPSAND-1924)