Places UI Kit: A ready-to-use library that provides room for customization and low-code development. Try it out, and share yourinput on your UI Kit experience.

Migrate to the new Place Search

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.

This page explains the differences between text-based place search features inthePlace class (new) andthePlacesService(legacy), and provides some code snippets for comparison.

The legacyPlacesService has the following text-based search methods:

  • ThefindPlaceFromQuery() method which takes a text query and returns asingle place result, and supports the use of place data fields.
  • ThefindPlaceFromPhoneNumber() method which lets you search for a placeusing a phone number, and supports the use of place data fields.
  • ThetextSearch() method which takes a text query and returns a list ofplace results.textSearch() is older, and does not support the use of placedata fields.

The newPlace class offers thePlace.searchByText() method, which lets yousearch for places using either a text query or phone number, and lets youcustomize your searches using an expanded selection of regularly updated placedata fields and place types.

The following table lists some of the main differences in place search methodsbetween thePlace class andPlacesService:

PlacesService (Legacy)Place (New)
findPlaceFromQuery()
findPlaceFromPhoneNumber()
searchByText()
FindPlaceFromQueryRequest
FindPlaceFromPhoneNumberRequest
SearchByTextRequest
Limited query options.More expansive query options.
Requires the use of a callback to handle the results object andgoogle.maps.places.PlacesServiceStatus response.Uses Promises, and works asynchronously.
Requires aPlacesServiceStatus check.No required status check, can use standard error handling.Learn more.
Supports only location bias.Supports location bias and location restriction.
Place data fields are formatted using snake case.Place data fields are formatted using camel case.
Returns a single place result.Returns up to 20 place results.
Limited to a fixed set ofplace types andplace data fields.Provides an expanded selection of regularly updatedplace types andplace data fields.
textSearch()
searchByText()
Returns all available data fields (asubset of the supported fields); cannot be constrained to specific fields.Returns only the requestedplace data fields.

Code comparison

This section compares code for text search methods to illustrate the differencesbetween the Places Service and thePlace class. The code snippets show the coderequired on each respective API to make a text-based search request.

Places Service (Legacy)

The following code snippet shows using thefindPlaceFromQuery() method tosearch for a place. The request is synchronous, and includes a conditional checkonPlacesServiceStatus. The needed place data fields are specified in therequest body, which is defined prior to making the actual request.

functionfindPlaces(){constrequest={query:"Museum of Contemporary Art Australia",fields:["name","geometry"],};// Create an instance of PlacesService.service=newgoogle.maps.places.PlacesService(map);// Make a findPlaceFromQuery request.service.findPlaceFromQuery(request,(results,status)=>{letplace=results[0];if(status===google.maps.places.PlacesServiceStatus.OK &&results){if(!place.geometry||!place.geometry.location)return;constmarker=newgoogle.maps.Marker({map,position:place.geometry.location,});map.setCenter(place.geometry.location);}});}

Learn more

Text Search (New)

The following code snippet shows using thesearchByText() method to searchfor places. The request is asynchronous, and does not require a status check(standard error handling can be used). In this example, the request includesamaxResultCount of 8 (value must be between 1 and 20). This function loopsthrough the results and adds a marker for each one, adjusting the map boundsbased on the position of the markers. Because thesearchByText() method usestheawait operator it can only be used inside anasync function.

asyncfunctionfindPlaces(){// Define a request.// The `fields` property is required; all others are optional.constrequest={fields:["displayName","location","businessStatus"],textQuery:"Tacos in Mountain View",includedType:"restaurant",locationBias:{lat:37.4161493,lng:-122.0812166},isOpenNow:true,language:"en-US",maxResultCount:8,minRating:3.2,region:"us",useStrictTypeFiltering:false,};// Call searchByText passing the request.const{places}=awaitgoogle.maps.places.Place.searchByText(request);// Add a marker for each result.if(places.length){constbounds=newgoogle.maps.LatLngBounds();places.forEach((place)=>{constmarkerView=newgoogle.maps.marker.AdvancedMarkerElement({map,position:place.location,title:place.displayName,});bounds.extend(place.location);console.log(place);});map.fitBounds(bounds);}else{console.log("No results");}}

ThesearchByText() method supports many more request options compared to theprevious version, including:

  • includedType which lets you constrain searches to a specific place type.
  • isOpenNow which lets you restrict searches to only return places that areopen.
  • minRating which lets you filter out results below the specified limit (forexample, only return places with three stars or more).
  • locationRestriction which omits results outside of the specified location(locationBias is also supported).

Learn more

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.