Skip to main content

๐Ÿงฉ Places Abstractions

The Places module defines a set of service abstractions that provide access to Google Places functionality.

These services expose high-level operations such as:

  • Autocomplete suggestions
  • Place search
  • Detailed place information (details, photos, reviews)

โš ๏ธ These interfaces are typically consumed through IPlacesService.


๐Ÿงพ IPlacesServiceโ€‹

Provides a unified entry point for all Places functionality.

public interface IPlacesService {
IAutocompleteService Autocomplete { get; }
IDetailsService Details { get; }
ISearchService Search { get; }
}

โš™๏ธ Responsibilitiesโ€‹

  • Aggregate all Places services
  • Provide a single access point for consumers

๐Ÿง  Notesโ€‹

  • Recommended entry point for most use cases
  • Avoids injecting multiple services individually

๐Ÿ” IAutocompleteServiceโ€‹

Provides autocomplete suggestions based on user input.

This service is typically the entry point of the Places workflow, where users provide partial input and receive suggestions that include a PlaceId.

The returned PlaceId can then be used to retrieve full place details via the IDetailsService.

public interface IAutocompleteService {
Task<IReadOnlyList<PlaceSuggestion>> SuggestPlacesAsync(
AutocompleteRequest autocompleteRequest
);
}

โš™๏ธ Responsibilitiesโ€‹

  • Retrieve predicted places from partial input
  • Support search-as-you-type scenarios

๐Ÿ‘‰ See: AutocompleteRequest

๐Ÿง  Notesโ€‹

  • Useful for UI inputs (search bars, forms)
  • Returns lightweight suggestion models -> see PlaceSuggestion

๐Ÿ” ISearchServiceโ€‹

Provides place search functionality.

This service represents another entry point of the Places workflow, allowing users to search for places using text queries or geographic constraints.

The results include PlaceId values, which can be used to fetch detailed information through the IDetailsService.

public interface ISearchService {
Task<IReadOnlyList<PlaceSearchResult>> SearchByTextAsync(string textQuery);
Task<IReadOnlyList<PlaceSearchResult>> SearchByNearbyAsync(NearbyRequest nearbyRequest);
}

โš™๏ธ Responsibilitiesโ€‹

  • Perform text-based searches
  • Perform location-based (nearby) searches -> see NearbyRequest

๐Ÿง  Notesโ€‹

  • Covers the most common discovery scenarios
  • Returns structured search results -> see PlaceSearchResult

๐Ÿ” IDetailsServiceโ€‹

Provides detailed information about places based on PlaceId.

public interface IDetailsService {
Task<PlaceDetails> GetDetailsAsync(string placeId);
Task<JsonDocument> GetDetailsRawAsync(string placeId, params string[] fields);
Task<IReadOnlyList<PlacePhoto>> GetPhotosAsync(string placeId, PhotoRequest? photoRequest = null);
Task<PlaceReviews> GetReviewsAsync(string placeId);
}

โš™๏ธ Responsibilitiesโ€‹

๐Ÿง  Notesโ€‹

  • Combines multiple endpoints into a single service
  • Raw access allows flexibility beyond mapped models
  • Designed for both simple and advanced use cases

โš ๏ธ Importantโ€‹

using var json = await detailsService.GetDetailsRawAsync(placeId);

The returned JsonDocument must be disposed properly.