歡迎參加 12 月在舊金山舉辦的
Google Maps Platform 開發人員社群日!
立即報名參加。
Google 會運用 AI 技術將內容翻譯成你偏好的語言,但可能會出錯。
合併程式庫
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Combine 是一個架構,可透過結合事件處理運算子來處理非同步事件。Combine 會集中事件處理程式碼,讓程式碼更容易閱讀及維護。
GoogleMapsPlatformCombine 程式庫是 Swift 程式庫,可傳回 Maps SDK for iOS 和 Places SDK for iOS 的 Publishers,以便您充分運用豐富的 Combine 功能。
安裝
如需系統需求和安裝操作說明,請參閱 GitHub 的 GoogleMapsPlatformCombine 程式庫說明文件。
使用案例:
GoogleMapsPlatformCombine 程式庫包含 GMSMapViewPublisher 類別,其中含有發布者屬性,可讓您訂閱地圖發出的事件。
設定 GMSMapViewPublisher 執行個體,訂閱攝影機變更事件:
let publisher = GMSMapViewPublisher(mapView: mapView)
publisher.didChangeCameraPosition.sink { cameraPosition in
print("Camera position at \(cameraPosition.target)")
}
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-10-25 (世界標準時間)。
[null,null,["上次更新時間:2026-10-25 (世界標準時間)。"],[],["The content introduces the GoogleMapsPlatformCombine library, which utilizes Apple's Combine framework for handling asynchronous events within the Google Maps and Places SDKs for iOS. It leverages `Publishers` to manage events. A key action is demonstrated through the `GMSMapViewPublisher` class, allowing users to subscribe to map events. An example illustrates how to monitor camera position changes using the `didChangeCameraPosition` publisher. Installation instructions and further details are available on the library's GitHub page.\n"]]