Migrate legacy Places Autocomplete to Places API (New)
If your address field uses google.maps.places.Autocomplete or AutocompleteService, it runs on the legacy Places API. Existing projects can keep using it, but new projects can't enable it, and it gets no new features. This guide moves both to Places API (New), with code you can adapt.
Where the legacy Places API stands
Google moved the legacy Places API and the JavaScript Places classes to Legacy status on 1 March 2025. According to Google's documentation as of November 2026:
- Places API (Legacy) can no longer be enabled for new Google Cloud projects, as of October 2026.
- Existing projects that already use it remain fully supported.
- Legacy services are feature frozen. New features only go to Places API (New).
- Google has not set a shutdown date. It has said it will give at least 12 months' notice before decommissioning legacy services.
So nothing breaks on a working site today. The risk comes when you reuse the code somewhere else. Copy the same autocomplete into a new site with a new Cloud project, and the legacy calls will be refused because the legacy API can't be enabled there.
How to tell you are on the legacy API
Search your code, theme or plugin for these names:
| Legacy (Places API) | Places API (New) replacement |
|---|---|
| new google.maps.places.Autocomplete(input, options) | PlaceAutocompleteElement |
| AutocompleteService.getPlacePredictions() | AutocompleteSuggestion.fetchAutocompleteSuggestions() |
| AutocompletePrediction | PlacePrediction |
| PlacesService.getDetails() | Place.fetchFields() |
| place_changed event and getPlace() | gmp-select event and placePrediction.toPlace() |
| SearchBox | No direct equivalent listed by Google |
The legacy widget also adds the CSS class pac-target-input to your input and renders suggestions in a .pac-container element, so either name in your stylesheet or page source is a strong sign. The Maps JavaScript API may also log a console message saying the class is not available to new customers.
Our scanner watches the page's network traffic and labels Places requests as legacy or new. It also types a test address into address-like fields to trigger autocomplete, so a scan shows which generation your form actually calls, and whether Google answered REQUEST_DENIED.
Before you change code: enable Places API (New)
- 01In Google Cloud Console, select the project that owns the key your page uses.
- 02Open the API Library, search for Places API (New) and enable it. It is a separate API from the legacy Places API.
- 03Open the key under Credentials. If API restrictions is set to restrict the key, add Places API (New) to the list alongside Maps JavaScript API.
- 04Leave the legacy Places API enabled until the migration is live, so the old code keeps working during the switch.
If you skip the restriction step, the new classes fail even though the API is enabled. See API restriction errors.
Migrating the Autocomplete widget
This is the common case: an address or location input with a dropdown of suggestions.
// Before: legacy widget attached to your own <input>
const input = document.getElementById("address");
const autocomplete = new google.maps.places.Autocomplete(input, {
componentRestrictions: { country: ["gb"] },
fields: ["formatted_address", "geometry", "name"],
});
autocomplete.addListener("place_changed", () => {
const place = autocomplete.getPlace();
if (!place.geometry) return; // user pressed Enter without choosing
form.address.value = place.formatted_address;
form.lat.value = place.geometry.location.lat();
form.lng.value = place.geometry.location.lng();
});
// After: PlaceAutocompleteElement renders its own input
const { PlaceAutocompleteElement } = await google.maps.importLibrary("places");
const placeAutocomplete = new PlaceAutocompleteElement({
includedRegionCodes: ["gb"],
});
document.getElementById("address-wrapper").appendChild(placeAutocomplete);
placeAutocomplete.addEventListener("gmp-select", async ({ placePrediction }) => {
const place = placePrediction.toPlace();
await place.fetchFields({ fields: ["displayName", "formattedAddress", "location"] });
form.address.value = place.formattedAddress;
form.lat.value = place.location.lat();
form.lng.value = place.location.lng();
});
The differences that catch people out:
- The element creates its own text input. You don't attach it to an existing <input>. Put a wrapper where the old field was, and use a hidden field if your form needs to submit the address.
- Option names changed. componentRestrictions.country becomes includedRegionCodes. types becomes includedPrimaryTypes. bounds biasing becomes locationBias, and strict bounds become locationRestriction.
- Fields are requested after selection. You call fetchFields() on the place, using camelCase names such as formattedAddress and displayName instead of formatted_address and name.
- The error event is gmp-error. Listen for it so a failed request doesn't fail silently.
- Your .pac-container CSS no longer applies. The new element has its own markup, so restyle it and check it on mobile.
The widget handles session tokens for you, covering the suggestion requests and the details request made when the user picks a result.
Migrating AutocompleteService
If you built your own dropdown with AutocompleteService, move to AutocompleteSuggestion. The new call returns a promise instead of taking a callback, and there is no status string to check.
// Before: callback with a status check
const service = new google.maps.places.AutocompleteService();
const token = new google.maps.places.AutocompleteSessionToken();
service.getPlacePredictions(
{ input: query, sessionToken: token, componentRestrictions: { country: "gb" } },
(predictions, status) => {
if (status !== google.maps.places.PlacesServiceStatus.OK || !predictions) return;
render(predictions.map((p) => ({ id: p.place_id, text: p.description })));
}
);
// After: promise-based, PlacePrediction objects
const { AutocompleteSuggestion, AutocompleteSessionToken } =
await google.maps.importLibrary("places");
let token = new AutocompleteSessionToken();
async function suggest(query) {
const { suggestions } = await AutocompleteSuggestion.fetchAutocompleteSuggestions({
input: query,
includedRegionCodes: ["gb"],
sessionToken: token,
});
render(
suggestions
.filter((s) => s.placePrediction)
.map((s) => ({ prediction: s.placePrediction, text: s.placePrediction.text.toString() }))
);
}
async function choose(prediction) {
const place = prediction.toPlace();
await place.fetchFields({ fields: ["formattedAddress", "location"] });
token = new AutocompleteSessionToken(); // start a new session for the next search
return place;
}
Calling fetchFields() on the place ends the session. Create a new token for each search session. Google notes that reusing a token across sessions causes requests to be billed individually.
Wrap the call in try/catch. Failures, including a disabled API or a key restriction, now arrive as rejected promises instead of a REQUEST_DENIED status.
WordPress and plugins
If the autocomplete comes from a form, checkout or store locator plugin, you can't migrate it yourself without forking the plugin. Check the plugin's changelog for Places API (New) support and update it. Until it supports the new API, keep the legacy Places API enabled on your existing project and don't move the site to a new Cloud project.
Confirm it works
- 01Load the page with the console open and type a partial address. Suggestions should appear.
- 02Pick one and check that every form field you fill (address, coordinates, postcode) receives a value.
- 03Watch the network tab. Requests should go to places.googleapis.com, not /maps/api/place/.
- 04Once live and stable, remove the legacy Places API from the key's API restrictions so nothing can fall back to it unnoticed.
Common questions
Do I have to migrate from the legacy Places Autocomplete now?
Not if your existing project already uses it: Google says existing projects remain fully supported and promises at least 12 months' notice before decommissioning. You do need the new API for any new Cloud project, because Places API (Legacy) can no longer be enabled on new projects.
Why does my autocomplete work on one site but not on a new one?
The new site is probably on a newer Cloud project where the legacy Places API isn't enabled and can't be. The legacy classes return REQUEST_DENIED there. Migrate the code to Places API (New).
Can I keep using my own input field with Places API (New)?
With PlaceAutocompleteElement, no: the element renders its own input. If you need full control of the input and dropdown, use AutocompleteSuggestion.fetchAutocompleteSuggestions and render the suggestions yourself.
Is there a replacement for SearchBox?
Google's migration table lists no direct equivalent for the legacy SearchBox. Most sites replace it with PlaceAutocompleteElement or a custom dropdown built on AutocompleteSuggestion.
A scan tells you in about twelve seconds, from a clean session.