googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.15k stars 136 forks source link

Elements inside MarkerInfoWindow can't handle Click events #541

Open dreson00 opened 6 months ago

dreson00 commented 6 months ago

Button inside MarkerInfoWindow can't handle click events because the window handles them. There should be an option to disable this so we can have buttons and other clickable elements inside info windows.

There is a similar issue closed with this comment:

Closing this issue, MarkerInfoWindow can handle ClickEvents:

   MarkerInfoWindow(
                state = rememberMarkerState(position = LatLng(1.35, 103.87)),
                onClick = {
                    Log.d("Hi", "I am a click event")
                    true
                }
            )

Originally posted by @kikoso in https://github.com/googlemaps/android-maps-compose/issues/200#issuecomment-1740872618

But this answer doesn't solve the problem at all. The onClick parameter is for the marker, not the window and the onInfoWindowClick: (Marker) -> Unit = {} parameter doesn't allow us to return Boolean.

Version

maps-compose version 4.3.0

Steps to reproduce

  1. Create a MarkerInfoWindow with a Button as content

Code example

MarkerInfoWindow(
    state = rememberMarkerState(
        position = LatLng(0.0,  0.0)
    ),
) {
    Text("Title")
    Button(
        onClick = {
            // do something
        }
    ) {
        Text("Button")
    }
wangela commented 6 months ago

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.

@dreson00 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.

CyberNut commented 6 months ago

Actual for me

LukePavelka commented 6 months ago

yes please.

darronschall commented 5 months ago

This might be by design? Per the documentation at https://developers.google.com/maps/documentation/android-sdk/infowindows#custom_info_windows the info window content is not designed to be interactive.

Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call [showInfoWindow()](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#showInfoWindow()). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.