android-maps-compose icon indicating copy to clipboard operation
android-maps-compose copied to clipboard

No shadows appear when creating custom cluster icons using composables

Open y9san9 opened this issue 2 years ago • 7 comments

Expected result: Shadows draw normally: Screenshot 2023-09-13 at 16 27 30

Actual result: Shadows do not draw: Screenshot 2023-09-13 at 16 33 15

Composable used in two cases: https://yaso.su/GuR06AbK

y9san9 avatar Sep 13 '23 13:09 y9san9

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: so we can see what is popular when we triage.

@y9san9 Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

wangela avatar Sep 13 '23 13:09 wangela

I am experiencing the same issue when adding a custom marker which contains of a card with elevation.

The code is:

MarkerComposable(
    state = MarkerState(position = LEIPZIG_LATLNG),
) {
    Card(
        elevation = CardDefaults.cardElevation(
            defaultElevation = 10.dp
        ),
        modifier = Modifier.padding(4.dp)
    ) {
        Text(text = "SOME TEXT", modifier = Modifier.padding(4.dp))
    }
}

Which renders like this in the preview: image

But looks like this on the map: image

And I noticed that not only outer shadows are missing, but also shadows within my compose view.

ln-12 avatar Oct 16 '23 16:10 ln-12

Is there any workaround?

y9san9 avatar Feb 09 '24 10:02 y9san9

Same issue here. I also tried drawing the shadow with graphicsLayer instead and it doesn't work, which is strange because other graphicsLayer parameters work but shadowElevation does not.

leontodd avatar Apr 08 '24 23:04 leontodd

Any update on this?

yasintanriverdi avatar Aug 28 '24 20:08 yasintanriverdi

Yeah, can confirm that the Shadow elevation does not work. Even with the Modifier.shadow() or with Card. Using custom shadow with graphics/canvas does not do justice to the UI.

DearDhruv avatar Jan 07 '25 16:01 DearDhruv

Any update on this? I have the same issue:

MarkerComposable(
    keys = arrayOf(location),
    state = MarkerState(position = location.location),
    anchor = Offset(0.5f, 0.5f),
    title = "${location.location.latitude}, ${location.location.longitude} - ${location.timestamp}",
    alpha = if (location.isSent) 1f else 0.8f,
    zIndex = 6.0f
) {
    Box(
        modifier = Modifier.shadow(elevation = 6.dp, shape = CircleShape)
    ) {
        Icon(
            modifier = Modifier.size(18.dp),
            imageVector = Icons.Default.Circle,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary
        )
    }
}

I tried putting the modifier in the Icon component too but it doesn't work as well

I have a workaround for anybody facing this:

MarkerInfoWindowComposable(
    keys = arrayOf(location),
    state = MarkerState(position = location.location),
    anchor = Offset(0.5f, 0.5f),
    title = "${location.location.latitude}, ${location.location.longitude} - ${location.timestamp}",
    alpha = if (location.isSent) 1f else 0.8f,
    zIndex = 6.0f
) {
    Box {
        Icon(
            modifier = Modifier
                .zIndex(1.0f)
                .size(18.dp),
            imageVector = Icons.Default.Circle,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary
        )

        Icon(
            modifier = Modifier
                .clip(CircleShape)
                .zIndex(0.0f)
                .offset(x = 0.dp, y = 4.dp)
                .alpha(0.1f)
                .size(18.dp),
            imageVector = Icons.Default.Circle,
            contentDescription = null,
            tint = DefaultShadowColor
        )
    }
}

It's a hack to make sure I get a shadow effect for my circle, but it works out

dragonfist453 avatar Apr 14 '25 16:04 dragonfist453