Android Google Maps 如何同时显示多个InfoWindows

Pio*_*Swi 5 android google-maps android-jetpack-compose

我想同时显示多个(在本例中为 2 个)信息窗口。我正在使用 Google Maps Compose 库。

这是我到目前为止所尝试过的:

GoogleMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState,
    uiSettings = uiSettings,
    properties = properties
) {

  val markerState = rememberMarkerState(position = someLocation)
  markerState.showInfoWindow()
  MarkerInfoWindow(
      state = markerState,
      icon = BitMapUtils.bitmapDescriptor(context, R.drawable.ic_own_position),
      content = {
          Text("Test")
      }
  )

  val markerState2 = rememberMarkerState(position = someLocation2)
  markerState2.showInfoWindow()
  MarkerInfoWindow(
      state = markerState2,
      icon = BitMapUtils.bitmapDescriptor(context, R.drawable.ic_own_position),
      content = {
              Text("Test")
      }
  )

}
Run Code Online (Sandbox Code Playgroud)

当我运行该应用程序时,InfoWindows 显示然后立即隐藏,这种情况会一直持续下去,直到内存消失并引发 OutOfMemory 异常。而且性能也很差

我还尝试showInfoWindow()在协程中执行。这解决了性能问题,但只有一个信息窗口永久可见。

有没有办法同时显示两个InfoWindows?