Page Summary
-
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 asGMSPlacesClient, returningFuturepublishers 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.
Combine is a framework for handling asynchronous events by combining event-processing operators. Combine makes your code easier to read and maintain by centralizing your event-processing code.
The GoogleMapsPlatformCombine library
is a Swift library that returns
Publishers
for the Maps SDK for iOS and Places SDK for iOS so that you
can take advantage of the rich set of Combine features.
Installation
For system requirements and installation instructions, see the GoogleMapsPlatformCombine library documentation on GitHub.
Example usage
The GoogleMapsPlatformCombine library provides extensions to the
GMSPlacesClient
class that return
Future
publishers for Places API calls.
Use the fetchPlace(id:, fields:, sessionToken:) -> Future<GMSPlace, Error>
extension to fetch place details:
GMSPlacesClient.shared() .fetchPlace( id: "placeId", fields: [.placeID, .name, .phoneNumber] ) .sink { completion in print("Completion \(completion)") } receiveValue: { place in print("Got place \(place.name ?? "")") }
What's next
- See the Combine library GitHub project page.