AI-generated Key Takeaways
-
SearchNearbyRequeststructures parameters for nearby place searches within a specified region. -
It allows filtering results by place types, including or excluding specific primary and regular types.
-
Users can customize the ranking preference (distance or prominence), the maximum number of results, and the properties returned for each place.
-
The request can be further refined using a region code and by specifying a circular search area with a center point and radius.
SearchNearbyRequest
struct SearchNearbyRequestextension SearchNearbyRequest : Equatable, Sendable-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Declaration
Swift
static func == (a: SearchNearbyRequest, b: SearchNearbyRequest) -> Bool -
How results will be ranked in the response.
Declaration
Swift
enum RankPreferenceextension SearchNearbyRequest.RankPreference : CaseIterable, Equatable, Hashable, Identifiable, Sendable -
The set of primary place types to exclude from a search. If conflicting types are specified (e.g., types appearing in
includedTypesandexcludedTypes), an INVALID_REQUEST error is returned. Up to 50 types can be specified. If a request is specified with multiple type restrictions, only places that satisfy all of the restrictions are returned. For more information about primary types see: https://developers.google.com/maps/documentation/places/web-service/nearby-search#includedtypesexcludedtypes,-includedprimarytypesexcludedprimarytypesDeclaration
Swift
var excludedPrimaryTypes: Set<PlaceType>? { get } -
The set of place types to exclude from a search. Up to 50 types can be specified. If a request is specified with multiple type restrictions, only places that satisfy all of the restrictions are returned. If conflicting types are specified (e.g., types appearing in
includedTypesandexcludedTypes), an INVALID_REQUEST error is returned.See Table A for a list of supported types https://developers.google.com/maps/documentation/places/web-service/place-types#table-a. */
Declaration
Swift
var excludedTypes: Set<PlaceType>? { get } -
The set of primary place types to include in a search. Up to 50 types can be specified. If a request is specified with multiple type restrictions, only places that satisfy all of the restrictions are returned. For more information about primary types see: https://developers.google.com/maps/documentation/places/web-service/nearby-search#includedtypesexcludedtypes,-includedprimarytypesexcludedprimarytypes
Declaration
Swift
var includedPrimaryTypes: Set<PlaceType>? { get } -
The set of place types to include in a search. Up to 50 types can be specified. If a request is specified with multiple type restrictions, only places that satisfy all of the restrictions are returned. If the set is empty, then all places of all types are returned.
See Table A for a list of supported types https://developers.google.com/maps/documentation/places/web-service/place-types#table-a. */
Declaration
Swift
var includedTypes: Set<PlaceType>? { get } -
init(locationRestriction:placeProperties:includedTypes:excludedTypes:includedPrimaryTypes:excludedPrimaryTypes:maxResultCount:rankPreference:regionCode:)
Instantiates a
SearchNearbyRequestwith a text query and place properties to return.Declaration
Swift
init(locationRestriction: any CoordinateRegionRestriction, placeProperties: [PlaceProperty], includedTypes: Set<PlaceType>? = nil, excludedTypes: Set<PlaceType>? = nil, includedPrimaryTypes: Set<PlaceType>? = nil, excludedPrimaryTypes: Set<PlaceType>? = nil, maxResultCount: Int = 20, rankPreference: SearchNearbyRequest.RankPreference = .popularity, regionCode: String? = nil)Parameters
locationRestrictionThe restricted region to search.
placePropertiesThe
PlacePropertys that should be included in place results. Must not be empty. An empty list will result in an error when trying to send the request.includedTypesThe set of place types to include in a search.
excludedTypesThe set of place types to exclude from a search.
includedPrimaryTypesThe set of primary place types to include in a search.
excludedPrimaryTypesThe set of primary place types to exclude from a search
maxResultCountThe maximum number of results to return. Must be between 1 and 20 (default), inclusive.
rankPreferenceThe
RankPreferenceto sort the results. Defaults to.popularity.regionCodeThe unicode country/region code (CLDR) of the request location.
-
The region to search specified as a circle, defined by center point and radius in meters. The radius must be between 0.0 and 50000.0, inclusive. The
locationRestrictionmust be specified withCircularCoordinateRegion. UsingRectangularCoordinateRegionwill result in an error.Declaration
Swift
var locationRestriction: any CoordinateRegionRestriction { get } -
The maximum number of
Placeresults to return. Must be between 1 and 20 (default) inclusive. Breaking this restriction will result in an error returned.Declaration
Swift
var maxResultCount: Int { get } -
The array of
PlacePropertythat should be included in place results.Declaration
Swift
var placeProperties: [PlaceProperty] { get } -
The
SearchNearbyRequest.RankPreferenceused to sort the results returned from the request. The default value is.distance.*/Declaration
Swift
var rankPreference: SearchNearbyRequest.RankPreference { get } -
The unicode country/region code (CLDR) of the location where the request is coming from.
See https://www.unicode.org/cldr/charts/44/supplemental/territory_language_information.html for region codes.
Declaration
Swift
var regionCode: String? { get }