Place Autocomplete (New)

  • The Autocomplete (New) service for iOS provides real-time place suggestions based on user input and customizable search criteria like location and place type.

  • Developers can refine search results using parameters like location restriction/bias, place type filters, and country limitations.

  • The API handles billing through session tokens and allows retrieval of detailed place information via a separate Place Details (New) request.

  • Autocomplete with Filter Comprehension demonstrates how to use filters like location restriction, bias, and place types to refine autocomplete suggestions, with code examples provided in Swift and Objective-C.

  • When using Autocomplete, attributions are required, including the Google logo, even if a map is not displayed alongside the suggestions.

European Economic Area (EEA) developers If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region.Learn more.

The Autocomplete (New) service is an iOS API thatreturns place suggestions in response to a request. In the request, specify atext search string and geographic bounds that control the search area.

The Autocomplete (New) service can match on fullwords and substrings of the input, resolving place names, addresses, andpluscodes. Applications can therefore send queries as the usertypes, to provide on-the-fly place suggestions.

Place suggestions are places, such as businesses, addresses, and points ofinterest, based on the specified input text string and search area.

For example, you call the API using as input a string that contains a partialuser input, "Spagh", with the search area limited to New York City. The responsethen contains a list ofplace suggestions that match the search string andsearch area, such as the restaurant named "Cafe Spaghetti", along with detailsabout the place.

The returnedplace suggestions are designed to be presented to the user sothat they can select the desired place. You can make aPlace Details(New) request to get moreinformation about any of the returned place suggestions.

You can integrate Autocomplete (New) functionality into your app in two mainways:

Note: The Autocomplete(New) widget is only available in the Places Swift SDK for iOS version 10.0.0and later. For more information, seePlaces Swift foriOS.

Get place predictions programmatically

Autocomplete (New) requests

Create an autocomplete request by calling a method on theGMSPlacesClient.You can pass parameters in theGMSAutocompleteRequestobject. The response provides Autocomplete suggestions within aGMSAutocompletePlaceSuggestionobject.

The API key andqueryparameters are required. You can also includeGMSAutocompleteSessionTokento associate requests with a billing session andGMSAutocompleteFilterto apply to the results.

Places Swift SDK version

Create an autocomplete request by calling a method on thePlacesClient.You can pass parameters in theAutocompleteRequestobject. The response provides Autocomplete suggestions within aAutocompletePlaceSuggestionobject.

The API key andquery parameters are required. You can also includeAutocompleteSessionTokento associate requests with a billing session andAutocompleteFilterto apply to the results.

For more information about required and optional parameters, seethe parameterssection of thisdocument.

Places Swift SDK

letcenter=(37.3913916,-122.0879074)letnorthEast=(37.388162,-122.088137)letsouthWest=(37.395804,-122.077023)letbias=RectangularCoordinateRegion(northEast:northEast,southWest:southWest)letfilter=AutocompleteFilter(types:[.restaurant],origin:center,coordinateRegionBias:bias)letautocompleteRequest=AutocompleteRequest(query:"Sicilian piz",filter:filter)switchawaitplacesClient.fetchAutocompleteSuggestions(with:autocompleteRequest){case.success(letautocompleteSuggestions):// Handle suggestions.case.failure(letplacesError):// Handle error.}

Swift

lettoken=GMSAutocompleteSessionToken()letnorthWestBounds=CLLocationCoordinate2DMake(40.921628,-73.700051)letsouthEastBounds=CLLocationCoordinate2DMake(40.477398,-74.259087)letfilter=GMSAutocompleteFilter()filter.types=[kGMSPlaceTypeRestaurant]filter.locationBias=GMSPlaceRectangularLocationOption(northWestBounds,southEastBounds)letrequest=GMSAutocompleteRequest(query:"Spagh")request.filter=filterrequest.sessionToken=tokenGMSPlacesClient.shared().fetchAutocompleteSuggestions(from:request,callback:{(results,error)inifleterror=error{print("Autocomplete error:\(error)")return}ifletautocompleteResults=results{forresultinautocompleteResults{print("Result\(String(describing:result.placeSuggestion?.placeID)) with\(String(describing:result.placeSuggestion?.attributedFullText))")}}})

Objective-C

CLLocationCoordinate2DnorthEast=CLLocationCoordinate2DMake(37.388162,-122.088137);CLLocationCoordinate2DsouthWest=CLLocationCoordinate2DMake(37.395804,-122.077023);GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.types=@[kGMSPlaceTypeRestaurant];filter.locationBias=GMSPlaceRectangularLocationOption(northEast,southWest);GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Sicilian piz"];request.sessionToken=token;request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*results,NSError*error){// Handle responsefor(GMSAutocompleteSuggestion*suggestioninresults){if(suggestion.placeSuggestion){// Show place suggestion data.}}}];

Autocomplete (New) responses

Autocomplete returns an array of up to fiveGMSAutocompleteSuggestion instances. The array contains:

  • placeID
  • types: Types that apply to this place.
  • distanceMeters: Distance from origin.
  • attributedFullText: Full human-readable text of a suggestion.
  • attributedPrimaryText: Human-readable primary text of a suggestion.
  • attributedSecondaryText: Human-readable secondary text of a suggestion.
  • structuredFormat: The specific name and disambiguating text, like city orregion.

Required parameters

query

The text string on which to search. Specify full words and substrings, placenames, addresses, andplus codes. TheAutocomplete (New) service returns candidate matchesbased on this string and orders results based on their perceived relevance.

Optional parameters

sessionToken

Session tokens are user-generated strings that trackAutocomplete (New) calls—both calls made through thewidget and programmatic calls—as "sessions."Autocomplete (New) uses session tokens to group thequery and selection phases of a user autocomplete search into a discrete sessionfor billing purposes.

You can expose your Places Autocomplete session token in order to pass it to other services that are not a part of the Places SDK for iOS, such as toAddress Validation:

Places Swift SDK

lettoken=AutocompleteSessionToken()letfilter=AutocompleteFilter(origin:CLLocationCoordinate2DMake(39.7,-94.5))letrequest=AutocompleteRequest(query:"Piz",sessionToken:token,filter:filter)PlacesClient.shared.fetchAutocompleteSuggestions(request:request){case.success(letsuggestions):...case.failure(letplacesError):print(placesError)}// pass token's string format to use with a service that is not a part of iOS SDK.print("token:\(token)")

Objective-C

GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Piz"];GMSAutocompleteSessionToken*token=[[GMSAutocompleteSessionTokenalloc]init];request.sessionToken=token;GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.origin=[[CLLocationalloc]initWithLatitude:39.7longitude:-94.5];filter.locationBias=GMSPlaceRectangularLocationOption(topLocation,bottomLocation);request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*_Nullableresults,NSError*_Nullableerror){...}];// pass token's string format to use with a service that is not a part of iOS SDK.NSLog(@"%@",token.description);

SeeSessiontokens for more information.

Optional AutocompleteFilter parameters

types

A place can only have asingle primary type from typesTableA orTableB associated with it.For example, the primary type might bemexican_restaurant orsteak_house.

By default, the API returns all places based on theinput parameter,regardless of the primary type value associated with the place. Restrict resultsto be of a certain primary type or primary types by passing thetypesparameter.

Use this parameter to specify up to five type values fromTableA orTableB. A place must matchone of the specified primary type values to be included in the response.

The request is rejected with anINVALID_REQUEST error if:

  • More than five types are specified.
  • Any unrecognized types are specified.

For example, to limit results to sporting goods stores, specify that type inyourAutocompleteFilter:

Places Swift SDK

letfilter=AutocompleteFilter(types:[PlaceType(rawValue:"sporting_goods_store")])

Swift

letfilter=GMSAutocompleteFilter()filter.types=["sporting_goods_store"]

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.types=@["sporting_goods_store"];

countries

Only include results from the list of specified regions, specified as an arrayof up to 15ccTLD ("top-leveldomain")two-character values. If omitted, no restrictions are applied to the response.For example, to limit the regions to Germany and France:

Places Swift SDK

letfilter=AutocompleteFilter(countries:["DE","FR"])

Swift

letfilter=GMSAutocompleteFilter()filter.countries=["DE","FR"]

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.countries=@[@"DE",@"FR"];

If you specify bothlocationRestriction andcountries, the results arelocated in the area of intersection of the two settings.

inputOffset

The zero-based Unicode character offset indicating the cursor position ininput. The cursor position can influence what predictions are returned. Ifempty, it defaults to the length ofinput.

locationBias or locationRestriction

You can specifylocationBias orlocationRestriction, but not both, to definethe search area. Think oflocationRestriction as specifying the region whichthe results must be within, andlocationBias as specifying the region that theresults must be near but can be outside of the area.

Note: If you omit bothlocationBias andlocationRestriction, then the APIuses IP biasing by default. With IP biasing, the API uses the IP address of thedevice to bias the results.
  • locationBias specifies an area to search. This location serves as a bias,which means results around the specified location can be returned, includingresults outside the specified area.

  • locationRestriction specifies an area to search. Results outside thespecified area are not returned.

Specify thelocationBias orlocationRestriction region as a rectangularviewport or as a circle.

A circle is defined by center point and radius in meters. The radius must bebetween 0.0 and 50000.0, inclusive. The default value is 0.0. ForlocationRestriction, you must set the radius to a value greater than 0.0.Otherwise, the request returns no results.

For example:

Places Swift SDK

letcenter=CLLocationCoordinate2DMake(40.477398,-74.259087)letbias=CircularCoordinateRegion(center:center,radius:1000.0)letfilter=AutocompleteFilter(coordinateRegionBias:bias)

Swift

letcenter=CLLocationCoordinate2DMake(40.730610,-73.935242)letradius=1000.0filter.locationBias=GMSPlaceCircularLocationOption(center,radius)

Objective-C

CLLocationCoordinate2Dcenter=CLLocationCoordinate2DMake(40.730610,-73.935242);radius=1000.0;GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.locationBias=GMSPlaceCircularLocationOption(center,radius);

A rectangle is a latitude-longitude viewport, represented as two diagonallyoppositelow andhigh points. A viewport is considered a closed region,meaning it includes its boundary. The latitude bounds must range between -90 to90 degrees inclusive, and the longitude bounds must range between -180 to 180degrees inclusive:

  • Iflow =high, the viewport consists of that single point.
  • Iflow.longitude >high.longitude, the longitude range is inverted (theviewport crosses the 180 degree longitude line).
  • Iflow.longitude = -180 degrees andhigh.longitude= 180 degrees, theviewport includes all longitudes.
  • Iflow.longitude = 180 degrees andhigh.longitude = -180 degrees, thelongitude range is empty.

Bothlow andhigh must be populated, and the represented box cannot beempty. An empty viewport results in an error.

For example, this viewport fully encloses New York City:

Places Swift SDK

letnorthEast=CLLocationCoordinate2DMake(40.477398,-74.259087)letsouthWest=CLLocationCoordinate2DMake(40.921628,-73.700051)letfilter=AutocompleteFilter(coordinateRegionBias:bias)

Swift

lethigh=CLLocationCoordinate2DMake(40.921628,-73.700051)letlow=CLLocationCoordinate2DMake(40.477398,-74.259087)letfilter=GMSAutocompleteFilter()filter.locationBias=GMSPlaceRectangularLocationOption(high,low)

Objective-C

CLLocationCoordinate2Dhigh=CLLocationCoordinate2DMake(40.477398,-74.259087);CLLocationCoordinate2Dlow=CLLocationCoordinate2DMake(440.921628,-73.700051);GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.locationBias=GMSPlaceRectangularLocationOption(high,low);

origin

The origin point from which to calculate straight-line distance to thedestination (returned asdistanceMeters). If this value is omitted,straight-line distance won't be returned. Must be specified as latitude andlongitude coordinates:

Places Swift SDK

letfilter=AutocompleteFilter(origin:CLLocation(latitude:37.395804,longitude:-122.077023))

Swift

letfilter=GMSAutocompleteFilter()filter.origin=CLLocation(latitude:37.395804,longitude:-122.077023)

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.origin=[[CLLocationalloc]initWithLatitude:37.395804longitude:-122.077023];

regionCode

The region code used to format the response, specified as accTLD ("top-leveldomain")two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, withsome notable exceptions. For example, the United Kingdom's ccTLD is "uk"(.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "TheUnited Kingdom of Great Britain and Northern Ireland").

If you specify an invalid region code, the API returns anINVALID_ARGUMENTerror. The parameter can affect results based on applicable law.

shouldIncludePureServiceAreaBusinesses

Iftrue, returns pure service area businesses in the response array. A pureservice area business is a business that visits or delivers to customersdirectly, but does not serve customers at their business address.

For example:

Places Swift SDK

letfilter=AutocompleteFilter()filter.shouldIncludePureServiceAreaBusinesses=true

Swift

letfilter=AutocompleteFilter()filter.shouldIncludePureServiceAreaBusinesses=true

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.shouldIncludePureServiceAreaBusinesses=YES;

Add the Place Autocomplete widget

To more easily provide a consistent place autocomplete experience, you can addthe Place Autocomplete widget to your app. The widget provides a dedicated,full-screen interface that handles user input and displays place predictions tothe user while returningAutocompletePlaceSuggestionobjects to the app. You can then make aPlace Details(New) request to getadditional information about any of the place predictions.

Note: The Autocomplete(New) widget is only available in the Places Swift SDK for iOS version 10.0.0and later. For more information, seePlaces Swift foriOS.

The place autocompletewidget

Like whengetting place predictions programmatically,the Place Autocomplete widget lets you usesessiontokens togroup autocomplete requests into session for billing purposes. You can pass asession token by callingAutocompleteSessionToken().

If you don't provide a session token, the widget will create an Autocompletesession token for you, which can then be obtained from theonSelectioncallback. For more information on using session tokens, seeAbout sessiontokens.

Note: Using session tokens is optional, but recommended.

When theshow binding value is set totrue, the user will be brought to afull screen view where they can select a place. As the user types, the widgetreturns suggestions for places such as businesses, addresses, and points ofinterest. When the user selects a place, the widget calls theonSelectionhandler with the selected place, and closes the fullscreen view.

Place Autocomplete widget parameters

In addition to theparameters availableprogrammatically,the Place Autocomplete widget also offers the following parameters.

show

show specifies whether the widget is shown.

onSelection

The closure to run when a place is selected.

onError

The closure to run when an error occurs. APlacesErrorwill be passed if an error occurs.

Content and theme customization

TheAutocompleteUICustomizationparameters specify the UI cusomizations to apply to the widget. Thecustomization options are:

  • AutocompleteListDensity.This parameter lets you choose the density of the suggestion list, eithermultiLine ortwoLine.
  • AutocompleteUIIcon.This parameter lets you choose whether to show the default icon for eachlist item.
  • theme.This parameter specifies a custom theme that overrides any of the defaultstyle attributes. You can customize the colors, typography, spacing,borders, and corners of your Place Autocomplete component. The default isPlacesMaterialTheme. Any theme attributes that are not overridden use thedefault styles.
Note: For reference on the theme attributes that you can customize, see the UIKitCustomstyling page.

See a full codeexample.

Autocomplete (New) examples

Use locationRestriction and locationBias

Autocomplete (New) uses IP biasing by default tocontrol the search area. With IP biasing, the API uses the IP address of thedevice to bias the results. You can optionally uselocationRestriction orlocationBias, but not both, to specifyan area to search.

Location restriction specifies the area to search. Results outside the specifiedarea are not returned. The following example uses location restriction to limitthe request to a circular location restriction with a 5000-meter radius centeredon San Francisco:

Places Swift SDK

letcenter=(37.775061,-122.419400)letradius=5000.0letrestriction=CircularCoordinateRegion(center:center,radius:radius)letfilter=AutocompleteFilter(coordinateRegionRestriction:restriction)lettoken=AutocompleteSessionToken()letautocompleteRequest=AutocompleteRequest(query:"Sicilian piz",sessionToken:token,filter:filter)switchawaitplacesClient.fetchAutocompleteSuggestions(with:autocompleteRequest){case.success(letautocompleteSuggestions):forsuggestioninautocompleteSuggestions{switchsuggestion{case.place:// Show place suggestion data.}}case.failure(letplacesError):// Handle error.}

Swift

lettoken=GMSAutocompleteSessionToken()letcenter=CLLocationCoordinate2DMake(37.775061,-122.419400)letradius=5000.0letfilter=GMSAutocompleteFilter()filter.locationRestriction=GMSPlaceCircularLocationOption(center,radius)letrequest=GMSAutocompleteRequest(query:"Piz")request.filter=filterrequest.sessionToken=tokenGMSPlacesClient.shared().fetchAutocompleteSuggestions(from:request,callback:{(results,error)inifleterror=error{print("Autocomplete error:\(error)")return}ifletautocompleteResults=results{forresultinautocompleteResults{print("Result\(String(describing:result.placeSuggestion?.placeID)) with\(String(describing:result.placeSuggestion?.attributedFullText))")}}})

Objective-C

CLLocationCoordinate2Dcenter=CLLocationCoordinate2DMake(37.775061,-122.419400);radius=5000.0;GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.locationRestriction=GMSPlaceCircularLocationOption(center,radius);GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Sicilian piz"];request.sessionToken=token;request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*results,NSError*error){// Handle responsefor(GMSAutocompleteSuggestion*suggestioninresults){if(suggestion.placeSuggestion){// Show place suggestion data.}}}];

With location bias, the location serves as a bias, which means results aroundthe specified location can be returned, including results outside the specifiedarea. The next example changes the previous request to use location bias:

Places Swift SDK

letcenter=(37.775061,-122.419400)letradius=5000.0letbias=CircularCoordinateRegion(center:center,radius:radius)letfilter=AutocompleteFilter(coordinateRegionBias:bias)lettoken=AutocompleteSessionToken()letautocompleteRequest=AutocompleteRequest(query:"Sicilian piz",sessionToken:token,filter:filter)switchawaitplacesClient.fetchAutocompleteSuggestions(with:autocompleteRequest){case.success(letautocompleteSuggestions):forsuggestioninautocompleteSuggestions{switchsuggestion{case.place:// Show place suggestion data.}}case.failure(letplacesError):// Handle error.}

Swift

lettoken=GMSAutocompleteSessionToken()letcenter=CLLocationCoordinate2DMake(37.775061,-122.419400)letradius=5000.0letfilter=GMSAutocompleteFilter()filter.locationBias=GMSPlaceCircularLocationOption(center,radius)letrequest=GMSAutocompleteRequest(query:"Piz")request.filter=filterrequest.sessionToken=tokenGMSPlacesClient.shared().fetchAutocompleteSuggestions(from:request,callback:{(results,error)inifleterror=error{print("Autocomplete error:\(error)")return}ifletautocompleteResults=results{forresultinautocompleteResults{print("Result\(String(describing:result.placeSuggestion?.placeID)) with\(String(describing:result.placeSuggestion?.attributedFullText))")}}})

Objective-C

CLLocationCoordinate2Dcenter=CLLocationCoordinate2DMake(37.775061,-122.419400);radius=5000.0;GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.locationBias=GMSPlaceCircularLocationOption(center,radius);GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Sicilian piz"];request.sessionToken=token;request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*results,NSError*error){// Handle responsefor(GMSAutocompleteSuggestion*suggestioninresults){if(suggestion.placeSuggestion){// Show place suggestion data.}}}];

Use types

Use the types parameter to restrict results from a request to be of a certaintype as listed inTableA andTableB. You can specify anarray of up to five values. If omitted, all types are returned.

The following example specifies a query string of "Soccer" and uses the typesparameter to restrict results to establishments of type"sporting_goods_store":

Places Swift SDK

letfilter=AutocompleteFilter(types:[PlaceType(rawValue:"sporting_goods_store")])lettoken=AutocompleteSessionToken()letautocompleteRequest=AutocompleteRequest(query:"Soccer",sessionToken:token,filter:filter)switchawaitplacesClient.fetchAutocompleteSuggestions(with:autocompleteRequest){case.success(letautocompleteSuggestions):forsuggestioninautocompleteSuggestions{switchsuggestion{case.place:// Show place suggestion data.}}case.failure(letplacesError):// Handle error.}

Swift

lettoken=GMSAutocompleteSessionToken()letfilter=GMSAutocompleteFilter()filter.types=["sporting_goods_store"]letrequest=GMSAutocompleteRequest(query:"Soccer")request.filter=filterrequest.sessionToken=tokenGMSPlacesClient.shared().fetchAutocompleteSuggestions(from:request,callback:{(results,error)inifleterror=error{print("Autocomplete error:\(error)")return}ifletautocompleteResults=results{forresultinautocompleteResults{print("Result\(String(describing:result.placeSuggestion?.placeID)) with\(String(describing:result.placeSuggestion?.attributedFullText))")}}})

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.types=@["sporting_goods_store"];GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Soccer"];request.sessionToken=token;request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*results,NSError*error){// Handle responsefor(GMSAutocompleteSuggestion*suggestioninresults){if(suggestion.placeSuggestion){// Show place suggestion data.}}}];

Use origin

When you include theorigin parameter in the request, specified aslatitude and longitude coordinates, the API includes the straight-line distancefrom the origin to the destination in the response. The response returns thedistance asdistanceMeters.

This example sets the origin to the center of San Francisco:

Places Swift SDK

letfilter=AutocompleteFilter(origin:CLLocation(latitude:37.7749,longitude:-122.4194))lettoken=AutocompleteSessionToken()letautocompleteRequest=AutocompleteRequest(query:"Amoeba",sessionToken:token,filter:filter)switchawaitplacesClient.fetchAutocompleteSuggestions(with:autocompleteRequest){case.success(letautocompleteSuggestions):forsuggestioninautocompleteSuggestions{switchsuggestion{case.place:// Show place suggestion data.}}case.failure(letplacesError):// Handle error.}

Swift

lettoken=GMSAutocompleteSessionToken()letorigin=CLLocation(latitude:37.7749,longitude:-122.4194)letfilter=GMSAutocompleteFilter()filter.origin=originletrequest=GMSAutocompleteRequest(query:"Amoeba")request.filter=filterrequest.sessionToken=tokenGMSPlacesClient.shared().fetchAutocompleteSuggestions(from:request,callback:{(results,error)inifleterror=error{print("Autocomplete error:\(error)")return}ifletautocompleteResults=results{forresultinautocompleteResults{print("Result\(String(describing:result.placeSuggestion?.placeID)) with\(String(describing:result.placeSuggestion?.attributedFullText)) and distance:\(String(describing:result.placeSuggestion?.distanceMeters))")}}})

Objective-C

GMSAutocompleteFilter*filter=[[GMSAutocompleteFilteralloc]init];filter.origin=[[CLLocationalloc]initWithLatitude:37.395804longitude:-122.077023];GMSAutocompleteRequest*request=[[GMSAutocompleteRequestalloc]initWithQuery:@"Amoeba"];request.sessionToken=token;request.filter=filter;[[GMSPlacesClientsharedClient]fetchAutocompleteSuggestionsFromRequest:requestcallback:^(NSArray<GMSAutocompleteSuggestion*>*results,NSError*error){// Handle responsefor(GMSAutocompleteSuggestion*suggestioninresults){if(suggestion.placeSuggestion){// Show place suggestion data.}}}];

Customize content and theme

Swift

letuiCustomization=AutocompleteUICustomization(listDensity:.multiLine,listItemIcon:.noIcon,theme:PlacesMaterialTheme())

Add a Places Autocomplete widget (full code)

Places Swift SDK

structPlaceAutocompleteDemoView:View{@StateprivatevarfetchedPlace:Place?@StateprivatevarplacesError:PlacesError?@StateprivatevarshowWidget=falsepublicvarbody:someView{VStack{Button("Search for a place"){showWidget.toggle()}.placeAutocomplete(show:$showWidget,onSelection:{(autocompletePlaceSuggestion,autocompleteSessionToken)inTask{letplacesClient=awaitPlacesClient.sharedletfetchPlaceRequest=FetchPlaceRequest(placeID:autocompletePlaceSuggestion.placeID,placeProperties:[.displayName,.formattedAddress],sessionToken:autocompleteSessionToken)switchawaitplacesClient.fetchPlace(with:fetchPlaceRequest){case.success(letplace):print("Fetched place:\(place)")self.fetchedPlace=placecase.failure(letplacesError):print("Failed to fetch place:\(placesError)")self.placesError=placesError}}},onError:{placesErrorinself.placesError=placesError})}}}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-21 UTC.