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

Compose MapboxMap SymbolLayer images in style #2467

Closed cholwell closed 1 month ago

cholwell commented 2 months ago

New Feature

I am using @Composable MapBoxMap with SymbolLayer.

Is there a better way to load images to the style, to use in an expression for iconImage than the following:

 MapboxMap(
        modifier = Modifier.fillMaxSize()
        mapState = mapState,
        mapViewportState = mapViewportState,
        style = {
             //empty
        }
    ) {
        MapEffect(true) { mapView ->
            mapView.mapboxMap.loadStyle(
                style("mapbox://my-style") {
                    +image("ic_some_icon", someIcon)
                }
            )
        }
        SymbolLayer(
            sourceState = sourceState,
            iconImage = ImageValue(
                Expression.image {
                    get("icon")
                }
            )
        )
    }

Why

This seems wrong but does work

kiryldz commented 2 months ago

@cholwell I guess this is what you are looking for.