Matthew Simoneau
Matthew Simoneau

Reputation: 6279

Google AutoCompleteService returns place with ID not known to PlacesService

I'm having problems with PlacesService.getDetails by "place id" for a result from AutoCompleteService.getPlacePredictions which returns these ids.

Here's my code (also at this JSFiddle):

function initService() {
  var placesService = new google.maps.places.PlacesService(window.document.createElement('div'));
  var autocompleteService = new google.maps.places.AutocompleteService();

  var showAddress = function(input) {
    autocompleteService.getPlacePredictions({ input }, displayTopSuggestion);
  }

  var displayTopSuggestion = function(predictions) {
    var placeId = predictions[0].place_id;
    placesService.getDetails({
      placeId: placeId
    }, function(place, status) {
      console.log(placeId + ": " + status);
    });
  }

  showAddress('401 Park Drive, Boston, MA');
  showAddress('120 Wall Street, New York, NY');
}

This displays "OK" for the first one (cool) and "NOT FOUND" for the second one (confusing):

ChIJdd3kdPR544kRllG3JcXaViQ: OK
ChIJq7N18T1awokRXtu1sjDO7Jw: NOT_FOUND

That is, the PlacesService doesn't know the placeId returned in the results from the AutocompleteService.

Does anyone know what is going on here?

Upvotes: 2

Views: 468

Answers (1)

miguev
miguev

Reputation: 4840

This seems like it may have been a manifestation of a transient issue in the Maps APIs: https://issuetracker.google.com/issues/63069427

Upvotes: 1

Related Questions