From e5f7813dd0f7089734ef42ae5576600c8494234c Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Fri, 6 Nov 2026 12:29:53 -0800 Subject: [PATCH 1/2] Redraw a marker when its URL icon's image arrives ImageIcon(imageUrl = ...) keeps the same instance when its image arrives; only its hashCode changes, and MarkerState makes the icon read recompose. Key the remembered bitmap on the hash as well, or the overlay keeps the transparent placeholder. --- .../java/com/mapconductor/maptiler/MapTilerAnnotations.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt b/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt index 555d703..106fca2 100644 --- a/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt +++ b/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt @@ -48,7 +48,9 @@ internal fun MapTilerMarkerOverlay( ) { val density = LocalDensity.current.density val scope = rememberCoroutineScope() - val bitmapIcon = remember(marker.icon) { (marker.icon ?: DefaultMarkerIcon()).toBitmapIcon() } + // URL の画像が届くと、アイコンは同じインスタンスのまま hashCode だけ変わる。それもキーにする。 + val icon = marker.icon + val bitmapIcon = remember(icon, icon?.hashCode()) { (icon ?: DefaultMarkerIcon()).toBitmapIcon() } val widthDp = remember(bitmapIcon) { (bitmapIcon.size.width / density).dp } val heightDp = remember(bitmapIcon) { (bitmapIcon.size.height / density).dp } From 67236a2808cea0b01d9ef6c948c20b6282e89005 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Fri, 6 Nov 2026 12:42:29 -0800 Subject: [PATCH 2/2] Key the marker bitmap on iconRevision MarkerState.icon no longer reads Compose state; iconRevision is the counter that goes up when a URL icon's image arrives. Reading it also makes the overlay recompose then. --- .../java/com/mapconductor/maptiler/MapTilerAnnotations.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt b/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt index 106fca2..0a2611f 100644 --- a/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt +++ b/src/main/java/com/mapconductor/maptiler/MapTilerAnnotations.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp import com.mapconductor.compose.info.InfoBubbleEntry import com.mapconductor.core.marker.DefaultMarkerIcon +import com.mapconductor.core.marker.iconRevision import com.mapconductor.core.marker.MarkerAnimation import com.mapconductor.core.marker.MarkerState import com.mapconductor.settings.Settings @@ -48,9 +49,10 @@ internal fun MapTilerMarkerOverlay( ) { val density = LocalDensity.current.density val scope = rememberCoroutineScope() - // URL の画像が届くと、アイコンは同じインスタンスのまま hashCode だけ変わる。それもキーにする。 - val icon = marker.icon - val bitmapIcon = remember(icon, icon?.hashCode()) { (icon ?: DefaultMarkerIcon()).toBitmapIcon() } + // URL の画像が届くと、アイコンは同じインスタンスのまま見た目だけ変わる。iconRevision が + // そのとき増えるので、それもキーにする(読むことで描き直しも起きる)。 + val bitmapIcon = + remember(marker.icon, marker.iconRevision) { (marker.icon ?: DefaultMarkerIcon()).toBitmapIcon() } val widthDp = remember(bitmapIcon) { (bitmapIcon.size.width / density).dp } val heightDp = remember(bitmapIcon) { (bitmapIcon.size.height / density).dp }