Skip to content

Commit 0c51438

Browse files
kikosodkhawk
andauthored
fix: fixed issue on MarkerComposable (#701)
Co-authored-by: Dale Hawkins <107309+dkhawk@users.noreply.github.com>
1 parent e429cbc commit 0c51438

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

maps-compose/src/main/java/com/google/maps/android/compose/RememberComposeBitmapDescriptor.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.google.maps.android.compose
22

3-
import android.graphics.Bitmap
4-
import android.graphics.Canvas
53
import android.view.View
64
import android.view.ViewGroup
75
import androidx.compose.runtime.Composable
@@ -15,6 +13,7 @@ import androidx.compose.ui.platform.LocalView
1513
import androidx.core.graphics.applyCanvas
1614
import com.google.android.gms.maps.model.BitmapDescriptor
1715
import com.google.android.gms.maps.model.BitmapDescriptorFactory
16+
import androidx.core.graphics.createBitmap
1817

1918
@Composable
2019
internal fun rememberComposeBitmapDescriptor(
@@ -37,7 +36,6 @@ private fun renderComposableToBitmapDescriptor(
3736
compositionContext: CompositionContext,
3837
content: @Composable () -> Unit,
3938
): BitmapDescriptor {
40-
val fakeCanvas = Canvas()
4139
val composeView =
4240
ComposeView(parent.context)
4341
.apply {
@@ -50,8 +48,6 @@ private fun renderComposableToBitmapDescriptor(
5048
}
5149
.also(parent::addView)
5250

53-
composeView.draw(fakeCanvas)
54-
5551
composeView.measure(measureSpec, measureSpec)
5652

5753
if (composeView.measuredWidth == 0 || composeView.measuredHeight == 0) {
@@ -62,12 +58,7 @@ private fun renderComposableToBitmapDescriptor(
6258
composeView.layout(0, 0, composeView.measuredWidth, composeView.measuredHeight)
6359

6460
val bitmap =
65-
Bitmap
66-
.createBitmap(
67-
composeView.measuredWidth,
68-
composeView.measuredHeight,
69-
Bitmap.Config.ARGB_8888,
70-
)
61+
createBitmap(composeView.measuredWidth, composeView.measuredHeight)
7162

7263
bitmap.applyCanvas { composeView.draw(this) }
7364

0 commit comments

Comments
 (0)