Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location button is not customizable #340

Closed
vladcioricagoogle opened this issue Jul 21, 2023 · 11 comments · Fixed by #347
Closed

Location button is not customizable #340

vladcioricagoogle opened this issue Jul 21, 2023 · 11 comments · Fixed by #347
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. released type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@vladcioricagoogle
Copy link

Current location button is not customizable and is not supporting overriding of the it's onClick method. There can be multiple use cases where the location should redirect the map to a specific location, not the current device location.

@vladcioricagoogle vladcioricagoogle added triage me I really want to be triaged. type: question Request for information or clarification. Not an issue. labels Jul 21, 2023
@wangela
Copy link
Member

wangela commented Jul 21, 2023

If you would like to upvote the priority of this issue, please comment below or react with 👍 so we can see what is popular when we triage.

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

@kikoso kikoso self-assigned this Jul 23, 2023
@kikoso kikoso added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed type: question Request for information or clarification. Not an issue. triage me I really want to be triaged. labels Jul 23, 2023
@wangela wangela added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Jul 24, 2023
@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bubenheimer
Copy link
Contributor

If I understand this change correctly, it adds an additional, distinct way of handling a click on the My Location button when using a custom Composable: the standard GoogleMap onMyLocationButtonClick parameter turns dead. Seems a bit odd.

@kikoso
Copy link
Collaborator

kikoso commented Oct 9, 2023

Hi @bubenheimer .

The standard Google Map listener setOnMyLocationButtonClickListener is ultimately used. This PR introduces two related features:

  • Customising the click listener.
  • Customising the Location button.

Both can be done independently, but ultimately feeding the standard setOnMyLocationButtonClickListener (see MapUpdater)

@bubenheimer
Copy link
Contributor

@kikoso what I am saying is that "customising the click listener" is not a new feature for android-maps-compose. It has always been available in android-maps-compose via the GoogleMap @Composable function's onMyLocationButtonClick parameter:
https://googlemaps.github.io/android-maps-compose/maps-compose/com.google.maps.android.compose/-google-map.html

After this change there are two different ways now to set a click listener. When customizing the button, then the GoogleMap function's onMyLocationButtonClick parameter is not used. (Because the default location button is not displayed, so its listener is not used.) That's not a good API design.

https://github.com/googlemaps/android-maps-compose/pull/347/files#diff-af1ccfc6ba10ae247813dd010f266980e46ae65e21dbae2f499636766dd9e275R123

The premise of this issue that "Current location button [] is not supporting overriding of [] it's onClick method" is wrong.

@bubenheimer
Copy link
Contributor

As for how to address this issue & PR in a better way: All the PR really offers is adding a button in addition to the map and disabling the map's default button. This can go in an example, there is no reason to clutter the library with it.

Also, the way this button is added to the GoogleMap AndroidView is a mess. There is no structural element around the AndroidView + Button combo, its appearance depends on whatever structural element is around the GoogleMap() call. Plus, the Button Row reuses the same modifier that's used on the AndroidView. And there is always this extra Row now, no matter if I have a custom button or not.

Please undo the addition of this PR, it merely destabilizes the existing API.

@FelixZY
Copy link

FelixZY commented Jul 2, 2024

I'm a a bit confused. I want to replace the default "my location" button with a custom button, but I want the button to act as the default "my location" button in every other respect (i.e. zoom to user's location with an appropriate zoom level and start following the user). As stated in the original request:

Current location button is not customizable and is not supporting overriding of the it's onClick method.

My understanding is that customization of the button was supported by the proposed implementation:

The standard Google Map listener setOnMyLocationButtonClickListener is ultimately used. This PR introduces two related features:

  • Customising the click listener.
  • Customising the Location button.

but was later removed in #428 .

Is customizing the button but not its onClick handler supported or do I need to implement a custom handler as in LocationTrackingActivity.kt now?

@kikoso
Copy link
Collaborator

kikoso commented Jul 2, 2024

Hi @FelixZY . #428 fixed a bug that was introduced previously. There is an example customising a location button in CustomControlsActivity.

TL;DR: deactivate local location button, implement your listener and add your Composable.

@FelixZY
Copy link

FelixZY commented Jul 2, 2024

@kikoso the "location button" in CustomControlsActivity simply shows a toast - it does not reposition the map to the current user location. It does not behave as the standard location button.

Screencast.from.2024-07-02.16.12.23.webm

@kikoso
Copy link
Collaborator

kikoso commented Jul 2, 2024

@FelixZY, that is intended to showcase a custom behavior on the location button. You would need to replace it with the intended behavior.

@FelixZY
Copy link

FelixZY commented Jul 2, 2024

Ok. What I would like though, is for my custom button to have the same behavior as the default button. My understanding is that OPs question included this ("Current location button is not customizable [...]"), and that #347 added support for this ("This PR introduces two related features [...] * Customising the Location button."). However, this was then seemingly reverted in #428.

From what I'm able to gather, it's not currently possible to get the default behavior when using a custom button. Instead, I would need to replicate the default behavior myself by listening to location updates and pushing them to the map myself, similarly to LocationTrackingActivity. Is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. released type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants