android-maps-compose
android-maps-compose copied to clipboard
Suggestion: don't set default map click listeners other than OnMapClickListener
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 Thank you for opening this issue. 🙏 Please check out these other resources that might be applicable:
- Support Console - If you have a support contract.
- Discord - chat with other developers
- StackOverflow - use the
google-mapstag - Google Maps Platform issue trackers
This is an automated message, feel free to ignore.
Thanks for reporting this issue. Maps Compose should mirror the same behavior as the underlying SDK so this should definitely be integrated.
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!
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
Thanks @fbarthelery for making this suggestion and @romainpiel for offering a fix! We're validating some of the behaviors reported here.
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.