Hi everyone! I am struggling with GoogleMaps and its snapshot functionality. In order to prepare a google map snapshot we should use the
liteMode
and SnapshotReadyCallback. With this code(code in thread), I am getting crash with error: Bitmap size needs to be more than 0. How can I set the initial size of the googleMap?
Piotr Prus
06/30/2021, 11:17 AM
Copy code
BoxWithConstraints(
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
) {
val zoomLevel = 11f
val options = GoogleMapOptions().apply {
camera(CameraPosition.fromLatLngZoom(location.toGoogleLatLng(), zoomLevel))
liteMode(true)
}
val map = rememberMapViewWithLifecycle(options)
coroutineScope.launch {
val googleMap = map.awaitMap()
googleMap.addMarker { position(location.toGoogleLatLng()) }
googleMap.snapshot {
snapshot = it
}
}
}
Piotr Prus
06/30/2021, 11:19 AM
where the snapshot field is:
Copy code
var snapshot by remember {
mutableStateOf(Bitmap.createBitmap(300, 200, Bitmap.Config.ARGB_8888))
}