组合库
Combine 是
框架,通过组合事件处理运算符来处理异步事件。
Combine 通过集中事件处理代码让您的代码更易于阅读和维护。
GoogleMapsPlatformCombine 库
是一个 Swift 库,会返回
Publishers
和 Places SDK for iOS,这样您就可以利用
丰富的 Combine 功能。
安装
请参阅
GoogleMapsPlatformCombine 库
了解最新的系统要求和安装说明。
用法示例
GoogleMapsPlatformCombine 库为
GMSPlacesClient
类,该类会返回
Future
。
以下示例使用 fetchPlace(id:, fields:, sessionToken:) -> Future<GMSPlace, Error>
用于获取地点详情的扩展程序:
GMSPlacesClient.shared()
.fetchPlace(
id: "placeId",
fields: [.placeID, .name, .phoneNumber]
)
.sink { completion in
print("Completion \(completion)")
} receiveValue: { place in
print("Got place \(place.name ?? "")")
}
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-21。
[null,null,["最后更新时间 (UTC):2025-03-21。"],[[["The GoogleMapsPlatformCombine library provides a way to use the Maps SDK for iOS and Places SDK for iOS with Apple's Combine framework for asynchronous event handling."],["This library offers extensions, like `fetchPlace`, to classes such as `GMSPlacesClient`, returning `Future` publishers for streamlined Places API calls."],["Using Combine's features with the Google Maps Platform can significantly enhance code readability and maintainability by centralizing event processing."],["Installation instructions and the latest system requirements for the GoogleMapsPlatformCombine library are available on its GitHub page."]]],[]]