Sam76
Sam76

Reputation: 11

Google Maps API - Migration of Autocomplete class to PlaceAutocompleteElement class

I got to know that Google is deprecating it's old places api and replacing with the new one's. In our application, we use Maps Javascript api with the library=places param, The following way: https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places. We are using Autocomplete class and a method in it getPlace() for our maps. But I have seen that the Autocomplete class is old and we have to migrate to new class PlaceAutocompleteElement - https://developers.google.com/maps/documentation/javascript/places-migration-overview#api-specific_changes

Do we really need to make changes to the old Autocomplete class and replace it with a new PlaceAutocompleteElement class? Is the old one getting deprecated any soon in the near time?

autocomplete = new GoogleApi.maps.places.Autocomplete(
      document.getElementById('startIcon'),
      {
        componentRestrictions: { country: country },
      },
    );

We also use some of the fields which autocomplete.getPlace() method offers. Like formatted_address, address_components, geometry.location, name and others. Even these data fields are getting replaced. So, the question is the same. Should I truly make any changes to my code and follow new Places class when using places library?

Do I require a new API key if I want to do the above changes? Because https://developers.google.com/maps/documentation/javascript/place-get-started#get-an-api-key-and-enable-the-required-apis says the new api key is only for new Text search but we are not using it.

Upvotes: 1

Views: 74

Answers (0)

Related Questions