Open m3-ra opened 2 months ago
Quick update: I tried to bump the sdk to the latest Mapbox compose version and use the method described here: https://docs.mapbox.com/android/maps/examples/compose/add-point-annotations/
val marker = rememberIconImage(key = markerResourceId, painter = painterResource(markerResourceId))
PointAnnotation(point = CityLocations.HELSINKI) {
iconImage = marker
textField = text
}
Which directly takes a drawable and no luck, icon is not mirrored when displayed
Further update after exploring the source code a bit.
rememberIconImage
converts the drawable to a bitmap with this:
internal fun Painter.drawToBitmap(): ImageBitmap {
val drawScope = CanvasDrawScope()
val bitmap = ImageBitmap(intrinsicSize.width.toInt(), intrinsicSize.height.toInt())
val canvas = Canvas(bitmap)
drawScope.draw(
density = Density(1f),
layoutDirection = LayoutDirection.Ltr,
canvas = canvas,
size = intrinsicSize
) {
draw(intrinsicSize)
}
return bitmap
}
With a clear hardcoded Ltr
direction which seems it could be the cultprit?
@m3-ra thanks for reporting, we'll take a look and report back.
Environment
Observed behavior and steps to reproduce
Mapbox doesn't seem to honor the
autoMirrored
attribute on vector drawables when rendering, which result in icons not being mirrored when the layout is RTL. Map used is mapbox compose and images are displayed with point annotations.Expected behavior
Icons should be mirrored
Notes / preliminary analysis
Now that I think about it, images are added with
style.addImage
which takes a bitmap... Could it be that the auto mirror info is lost when doing Drawable -> Bitmap?Additional links and references