-
Notifications
You must be signed in to change notification settings - Fork 149
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
How to show images downloaded from network efficiently? #210
Comments
How will clustering help in this situation? |
I have this exact same issue. Did you end up finding any solutions? |
No. Enabled disk caching so next time it won't take much time. Also i am not using large images in the markers. |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
rendering async images is still a problem i think. |
using a key to trigger re-composition of the marker when the image is loaded does not work for me. (using coil)
|
I've found out that using clustering plus the var mapSize by remember { mutableStateOf(IntSize.Zero) }
GoogleMap(
modifier = Modifier
.fillMaxSize()
.onGloballyPositioned { mapSize = it.size },
cameraPositionState = cameraPositionState,
) {
val coroutineScope = rememberCoroutineScope()
if (!state.mapItems.isNullOrEmpty()) {
val clusterManager = rememberClusterManager<CollaboratorsMapItem>()
val renderer = rememberClusterRenderer(
clusterContent = null,
clusterItemContent = { item ->
AndroidView(
factory = { context ->
ImageView(context).apply {
scaleType = ImageView.ScaleType.CENTER_CROP
layoutParams = ViewGroup.LayoutParams(56.toPxSize, 56.toPxSize)
load(item.collaborator.imageUrl) {
allowHardware(false)
crossfade(false)
error(com.veeva.link.library.ui.R.drawable.ui_img_default_profile)
fallback(com.veeva.link.library.ui.R.drawable.ui_img_default_profile)
placeholder(com.veeva.link.library.ui.R.drawable.ui_img_default_profile)
}
}
},
modifier = Modifier
.size(56.dp)
.border(3.dp, MaterialTheme.colorScheme.surface.copy(alpha = ContentAlpha.medium), CircleShape)
.padding(3.dp)
.clip(CircleShape),
)
},
clusterManager = clusterManager,
)
SideEffect {
clusterManager ?: return@SideEffect
clusterManager.algorithm = NonHierarchicalViewBasedAlgorithm(mapSize.width.toDp.roundToInt(), mapSize.height.toDp.roundToInt())
}
SideEffect {
if (clusterManager?.renderer != renderer && renderer != null) {
(renderer as DefaultClusterRenderer).minClusterSize = 2
clusterManager?.renderer = renderer
}
}
if (clusterManager != null) {
Clustering(
items = state.mapItems,
clusterManager = clusterManager,
)
}
}
} |
Basically what I am doing is downloading the images from server and making an icon with the icon generator. After all the icons has been fully generated then I am putting the markers in the map. But from large list of markers it will take too much time to draw the markers. So how to do this in an optimized way?
I tried to recompose the markers each time the image is downloaded but it got stuck in infinite recompose.
The text was updated successfully, but these errors were encountered: