GoogleMap.OnMyLocationButtonClickListener
公共方法
当点击“我的位置”按钮时调用。
此方法在 Android 界面线程上调用。
如果您需要获取用户的当前位置,请使用 com.google.android.gms.location.FusedLocationProviderApi。
返回
- 如果监听器使用了事件(即不应发生默认行为),则为
true
;否则为 false
(即应该发生默认行为)。默认行为是让镜头以用户位置为中心移动。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-08。
[null,null,["最后更新时间 (UTC):2025-07-08。"],[[["`GoogleMap.OnMyLocationButtonClickListener` is an interface used to handle clicks on the \"My Location\" button within a Google Map."],["The primary method, `onMyLocationButtonClick()`, is called when the button is clicked and allows custom actions to be performed before or instead of the default camera movement."],["Returning `true` from `onMyLocationButtonClick()` prevents the default behavior (centering the camera on the user's location), while returning `false` allows it."]]],["The `GoogleMap.OnMyLocationButtonClickListener` interface triggers the `onMyLocationButtonClick()` method when the \"My Location\" button is pressed. This method, executed on the UI thread, allows developers to handle the event. Returning `true` prevents the default camera movement to the user's location, while `false` allows it. For retrieving the user's location, the `FusedLocationProviderApi` is recommended.\n"]]