MapsInitializer
如果您在取得地圖前需要使用功能,請使用這個類別初始化 Google Maps SDK for Android。由於部分類別 (例如 BitmapDescriptorFactory 和 CameraUpdateFactory) 需要初始化,因此必須呼叫此方法。
如果您使用的是 MapFragment
或 MapView
,並已對其中一個類別呼叫 getMapAsync()
並等待 onMapReady(GoogleMap map)
回呼,藉此取得 (非空值) GoogleMap
,就不必擔心這個類別。請參考範例應用程式的範例。
公用方法摘要
同步的靜態 int
|
initialize(情境脈絡) 初始化 Google Maps SDK for Android,確保類別可供使用。
|
繼承方法摘要
來自類別
java.lang.Object
布林值
|
equals(物件 arg0)
|
最終等級<?>
|
getClass()
|
int
|
hashCode()
|
最後
void
|
notify()
|
最後
void
|
notifyAll()
|
字串
|
toString()
|
最後
void
|
wait(long arg0, int arg1)
|
最後
void
|
wait(Long arg0)
|
最後
void
|
wait()
|
公用方法
公開靜態同步 int
initialize
(情境結構定義)
參數
context |
用於擷取必要的 SDK 資源和程式碼。不得為 null 。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-16 (世界標準時間)。
[null,null,["上次更新時間:2025-06-16 (世界標準時間)。"],[[["The `MapsInitializer` class is used to initialize the Google Maps SDK for Android, particularly when features are needed before a map is obtained."],["It's crucial to call `MapsInitializer.initialize()` because classes like `BitmapDescriptorFactory` and `CameraUpdateFactory` require prior initialization."],["If you're using `MapFragment` or `MapView` and have a non-null `GoogleMap` instance through `getMapAsync()`, you don't need to explicitly call `MapsInitializer.initialize()`."],["The `initialize()` method takes a Context as a parameter and returns a `ConnectionResult` error code indicating the success of the initialization."]]],["The `MapsInitializer` class initializes the Google Maps SDK for Android, enabling the use of classes like `BitmapDescriptorFactory` and `CameraUpdateFactory`. It is necessary when map features are used before obtaining a map. Initialization is performed via the `initialize(Context context)` method, which requires a non-null context. This step is not required if a `GoogleMap` is already obtained via `getMapAsync()` on `MapFragment` or `MapView`. The method returns a `ConnectionResult` error code.\n"]]