Skip to content

fix: fixed issue on MarkerComposable #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: fixed issue on MarkerComposable
  • Loading branch information
kikoso committed Apr 10, 2025
commit b7fa7a852c3da4da16f7b5055d709b031e25729a
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.google.maps.android.compose

import android.graphics.Bitmap
import android.graphics.Canvas
import android.view.View
import android.view.ViewGroup
import androidx.compose.runtime.Composable
Expand All @@ -15,6 +13,7 @@ import androidx.compose.ui.platform.LocalView
import androidx.core.graphics.applyCanvas
import com.google.android.gms.maps.model.BitmapDescriptor
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import androidx.core.graphics.createBitmap

@Composable
internal fun rememberComposeBitmapDescriptor(
Expand All @@ -37,7 +36,6 @@ private fun renderComposableToBitmapDescriptor(
compositionContext: CompositionContext,
content: @Composable () -> Unit,
): BitmapDescriptor {
val fakeCanvas = Canvas()
val composeView =
ComposeView(parent.context)
.apply {
Expand All @@ -50,8 +48,6 @@ private fun renderComposableToBitmapDescriptor(
}
.also(parent::addView)

composeView.draw(fakeCanvas)

composeView.measure(measureSpec, measureSpec)

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

val bitmap =
Bitmap
.createBitmap(
composeView.measuredWidth,
composeView.measuredHeight,
Bitmap.Config.ARGB_8888,
)
createBitmap(composeView.measuredWidth, composeView.measuredHeight)

bitmap.applyCanvas { composeView.draw(this) }

Expand Down
Loading