Combine Library

  • 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.

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

See the GoogleMapsPlatformCombine library documentation on GitHub for the latest system requirements and installation instructions.

Example Usage

The GoogleMapsPlatformCombine library provides extensions to the GMSPlacesClient class which return Future publishers for Places API calls.

The following example uses 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