Open HannesSundin opened 1 year ago
@HannesSundin Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:
google-maps
tagThis is an automated message, feel free to ignore.
@HannesSundin , can you provide a code snippet showcasing your case? Thanks!
val context = LocalContext.current
val density = LocalDensity.current
val coroutineScope = rememberCoroutineScope()
val cameraPositionState = rememberCameraPositionState {
position = initialCameraPosition
}
GoogleMap(
onMapLoaded = {
setZoomLevel(cameraPositionState.getZoomLevel())
setBounds(cameraPositionState.getBounds())
onMapReady()
},
cameraPositionState = cameraPositionState,
uiSettings = MapUiSettings(
myLocationButtonEnabled = true,
zoomControlsEnabled = false,
mapToolbarEnabled = false,
compassEnabled = false
),
contentPadding = PaddingValues(bottom = sheetPeekHeight + 32.dp),
properties = MapProperties(
isBuildingEnabled = false,
isMyLocationEnabled = true,
isIndoorEnabled = false,
isTrafficEnabled = false,
mapStyleOptions = MapStyleOptions.loadRawResourceStyle(
context,
R.raw.map_style_night
)
),
) {
LaunchedEffect(cameraPositionState.isMoving) {
if (!cameraPositionState.isMoving) {
setBounds(cameraPositionState.getBounds())
setZoomLevel(cameraPositionState.getZoomLevel())
}
}
LaunchedEffect(zoomToBounds) {
zoomToBounds?.let {
cameraPositionState.animate(it.toCameraUpdate(density), 500)
}
}
val markerInfoWindowState = rememberMarkerState()
var clickedIcon: Pair<String?, String?>? by remember {
mutableStateOf(null)
}
mailboxes.forEach {
Marker(
state = MarkerState(it.mailbox.location),
icon = context.bitmapDescriptorFromVector(R.drawable.ic_map_pin),
snippet = it.mailbox.countryCode,
tag = MARKER_MAILBOX,
title = it.mailbox.mailboxId,
visible = true,
zIndex = 0.0f,
onClick = {
clickedIcon = it.title to it.snippet
markerInfoWindowState.position = it.position
true
},
)
}
Clustering(
items = items,
onClusterClick = { cluster ->
val positions = cluster.items.map { it.position }
val bounds = LatLngBounds.builder().apply {
positions.forEach { include(it) }
}.build()
val cameraUpdate = bounds.toCameraUpdate(density = density)
coroutineScope.launch {
cameraPositionState.animate(
cameraUpdate,
context.resources.getInteger(android.R.integer.config_longAnimTime)
)
}
true
},
onClusterItemInfoWindowClick = {
onLocationClicked(
Id(
id = it.title,
countryCode = it.countryCode,
type = if (it.distributionPointType.isServicePoint()) {
LocationId.Type.SP
} else LocationId.Type.PB
)
)
},
onClusterItemClick = {
clickedIcon = it.title to it.snippet
markerInfoWindowState.position = it.position
markerInfoWindowState.showInfoWindow()
true
},
clusterContent = {
Image(
modifier = Modifier.wrapContentSize(),
painter = painterResource(
R.drawable.graphics_map_pin_cluster
),
contentDescription = null,
)
},
clusterItemContent = {
Image(
modifier = Modifier.wrapContentSize(),
painter = painterResource(
it.getPinResource(MapMode.Default),
),
contentDescription = null,
)
}
)
if (clickedIcon != null) {
MarkerInfoWindow(
state = markerInfoWindowState,
icon = context.bitmapDescriptorFromVector(R.drawable.ic_map_pin),
title = clickedIcon!!.first,
snippet = clickedIcon!!.second,
zIndex = Float.MAX_VALUE,
onInfoWindowClick = {
}
) {
InfoWindow(title = it.title, snippet = it.snippet)
}
}
}
Its hard to reproduce it but here is the code i was using, it didnt happen that many times but I got one crash at least
Environment details
"com.google.maps.android:maps-compose:2.14.0" "com.google.maps.android:maps-compose-utils:2.11.0"
Steps to reproduce
Stack trace