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

Suggestion: don't set default map click listeners other than OnMapClickListener

Open fbarthelery opened this issue 2 years ago • 3 comments

MapView use a layer approach to handle click on map element. If a click is not handled by a high layer, a lower layer will be able to handle it. For exemple, when a click on a POI occurs, the POI layer will invoke OnPoiClickListener if it is set. If it isn't set the OnMapClickListener will be called. (Note: I'm not sure of the exact implementation details, I just described what I think it is)

GoogleMap() composable always set OnPoiClickListener, OnMyLocationClickListener, so the fallback to OnMapClickListener and the associate onMapClick callback is never called and you are forced to implement onPOIClick to handle the click even if you don't care about the POI. MapView also has a default behavior for the onMapClick if you don't set OnMapClickListener that you may want to preserve

fbarthelery avatar Feb 16 '22 17:02 fbarthelery

@fbarthelery Thank you for opening this issue. 🙏 Please check out these other resources that might be applicable:

This is an automated message, feel free to ignore.

jpoehnelt avatar Feb 16 '22 17:02 jpoehnelt

Thanks for reporting this issue. Maps Compose should mirror the same behavior as the underlying SDK so this should definitely be integrated.

arriolac avatar Feb 16 '22 17:02 arriolac

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!

stale[bot] avatar Jul 10 '22 11:07 stale[bot]

I think even OnMapClickListener should not be set by default. The current implementation prevents clicks on a parent composable.

For example:

Box(Modifier.clickable { foo() }) {
  GoogleMap()
}

foo() will never be called on a click

romainpiel avatar May 22 '23 08:05 romainpiel

Thanks @fbarthelery for making this suggestion and @romainpiel for offering a fix! We're validating some of the behaviors reported here.

wangela avatar Aug 04 '23 18:08 wangela

Hi, this is also a usability issue, because it prevents users from clicking on markers they are standing directly in front of. onMyLocationClick is not nullable, so it always sets a OnMyLocationClickListener on the underlying MapView, which causes the "my location" layer to intercepts clicks.

Tetr4 avatar Aug 17 '23 15:08 Tetr4