GoogleMap.OnMyLocationButtonClickListener
公用方法
在使用者按下我的位置按鈕時呼叫。
系統會在 Android UI 執行緒上呼叫此方法。
如果您需要取得使用者目前的位置,請使用 com.google.android.gms.location.FusedLocationProviderApi。
傳回
- 如果事件監聽器使用事件 (也就是說,不應發生預設行為),則為
true
;否則應使用 false
(也就是說,應發生預設行為)。預設行為是在相機移動時以使用者位置為中心。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-13 (世界標準時間)。
[null,null,["上次更新時間:2025-06-13 (世界標準時間)。"],[[["`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"]]