Google 会使用 AI 技术将内容翻译成您偏好的语言。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)")
}
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-10-16。
[null,null,["最后更新时间 (UTC):2026-10-16。"],[],["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"]]