Google Maps Platform 即将推出全新地图样式。此次地图样式更新包括全新默认调色板,以及地图体验和易用性方面的改进。所有地图样式将于 2025 年 3 月自动更新。如需详细了解适用范围以及如何提前选择启用,请参阅
全新 Google Maps Platform 地图样式。
组合库
Combine 是
框架,通过组合事件处理运算符来处理异步事件。
Combine 通过集中事件处理代码让您的代码更易于阅读和维护。
GoogleMapsPlatformCombine 库
是一个 Swift 库,会返回
Publishers
和 Places SDK for iOS,这样您就可以利用
丰富的 Combine 功能。
安装
请参阅
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):2024-09-13。
[null,null,["最后更新时间 (UTC):2024-09-13。"],[[["GoogleMapsPlatformCombine is a Swift library that integrates the Maps SDK for iOS and Places SDK for iOS with Apple's Combine framework."],["This library provides Publishers for various SDK functionalities, allowing developers to leverage Combine's features for asynchronous event handling."],["By using GoogleMapsPlatformCombine, developers can simplify their code and centralize event-processing logic for Google Maps and Places SDKs within their applications."],["A practical example demonstrates subscribing to camera change events on a `GMSMapView` using the `GMSMapViewPublisher` and Combine's `sink` operator."]]],[]]