Placeresult object returned from autocomplete getPlace () skips multiple properties

Calling autocomplete.getPlace () returns the returned PlaceResult object without the name formatted_phone_number, international_phone_number, rating, and website properties. When I do console.log of the place object, this is what is returned:

address_components: Array[8]
formatted_address: "Google Sydney, 5/48 Pirrama Rd, Pyrmont NSW 2009, Australia"
geometry: Object
html_attributions: Array[0]
icon: ""
id: "20074bf275d0d9476ed98e17445c8c19531e0c20"
name: "Google Sydney"
reference: "CnRlAAAASdbJCc7CCRHiL1gb7Z7BwJ9dLXhM16AexHOmugvvuC9t4o_RqKpgrq57CkIjS_YO7iCHtmypMjOFCkhc4zBGF882PHQW4Bv2rHEvePPfIrjWxT4VjYF7N-5SveVoPT7xe-jfWzH7YZDWeDxKyYFE2xIQJQb58Lr_dkmCmYVATfeObBoU1SmGG30mBXMR4TavRMo9XZNX8L4"
types: Array[2]
url: ""
vicinity: "Pyrmont"
__proto__: Object


Note that the properties mentioned above in Placeresult no longer exist. These properties were definitely showing up in Placeresult from a call to autocomplete.getPlace () in the last week or so. Placeresult objects from service.getDetails () correctly return all the properties mentioned in the Places V3 API, however the call to .getPlace () now skips these attributes despite referencing the same Placeresult. Any idea why these properties are missing now?


  function initialize() {
    var mapOptions = {
      center: new google.maps.LatLng(-33.8688, 151.2195),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    var map = new google.maps.Map(document.getElementById('map_canvas'),

    var input = document.getElementById('searchTextField');
    var autocomplete = new google.maps.places.Autocomplete(input);

    autocomplete.bindTo('bounds', map);

    var infowindow = new google.maps.InfoWindow();
    var marker = new google.maps.Marker({
      map: map

    google.maps.event.addListener(autocomplete, 'place_changed', function() {
      var place = autocomplete.getPlace();
      if (place.geometry.viewport) {
      } else {w
        map.setZoom(17);  // Why 17? Because it looks good.

      var image = new google.maps.MarkerImage(
          new google.maps.Size(71, 71),
          new google.maps.Point(0, 0),
          new google.maps.Point(17, 34),
          new google.maps.Size(35, 35));

      var address = '';
      if (place.address_components) {
        address = [(place.address_components[0] &&
                    place.address_components[0].short_name || ''),
                   (place.address_components[1] &&
                    place.address_components[1].short_name || ''),
                   (place.address_components[2] &&
                    place.address_components[2].short_name || '')
                  ].join(' ');

      infowindow.setContent('<div><strong>' + + '</strong><br>' + address);, marker);

    // Sets a listener on a radio button to change the filter type on Places
    // Autocomplete.
    function setupClickListener(id, types) {
      var radioButton = document.getElementById(id);
      google.maps.event.addDomListener(radioButton, 'click', function() {

    setupClickListener('changetype-all', []);
    setupClickListener('changetype-establishment', ['establishment']);
    setupClickListener('changetype-geocode', ['geocode']);
  google.maps.event.addDomListener(window, 'load', initialize);



source to share

1 answer

The Places-API is still experimental, so when you say you got phone numbers last week, they might have changed something.

But, however, you are correct, what you get is placeSearchResponse and not placeDetailsResponse (which it should be).



All Articles