自动完成谷歌Javascript

自动完成谷歌Javascript,javascript,google-maps,autocomplete,google-places-api,Javascript,Google Maps,Autocomplete,Google Places Api,嗨,我很难让自动完成像这样显示。我的代码用于提交并正确显示地图,但不显示自动完成的结果。我想知道可能是什么问题 这是我的HTML <div id="floating-panel"> //this is the text field that does not display the autocomplete <input id="address" placeholder="Enter Starting Location" type="text"/> <

嗨,我很难让自动完成像这样显示。我的代码用于提交并正确显示地图,但不显示自动完成的结果。我想知道可能是什么问题

这是我的HTML

<div id="floating-panel">

  //this is the text field that does not display the autocomplete
  <input id="address" placeholder="Enter Starting Location" type="text"/>

  <input id="submit" type="button" value="Directions">
</div>

<div id="right-panel"></div>
<div id="map"></div>
这是我对autocomplete的调用,API已启用,我看到对数据进行了调用,但没有返回结果:

 https://maps.googleapis.com/maps/api/js?key=xxx&libraries=places&callback=initMap: {type: external, attributes: {async: true}}

我用非常相似的代码得到了同样的结果。对我来说,这段代码已经运行了几个月,就在今天,我从一位用户那里收到一份报告,显示的位置下拉列表不再显示

var input = $("input[name='location']");
var formattedAddress = input.next("input[name='formattedLocation']");
var searchBox = new google.maps.places.SearchBox(input[0]);
searchBox.addListener('places_changed', function() {
   var places = searchBox.getPlaces();
   if (places.length == 0) {
      formattedAddress.val('');
      return;
   }

   formattedAddress.val(places[0].formatted_address);
 });
我在想也许我们超过了我们的每日配额,但从谷歌API控制台上看似乎不是这样。我在浏览器控制台中没有看到任何错误。如果我查看开发人员工具网络选项卡,我可以看到请求将返回,但响应似乎相当神秘,例如:/**/xdc.\u 490z0c&&xdc.\u 490z0c[4],因此我无法判断是否有好的数据返回

我想知道最近谷歌方面是否发生了一些我从未听说过的变化


如果您使用的是标准计划,请指定您希望使用的是发行版而不是实验版。

谷歌地图API在其新版本中有新的安全更改,请使用3.0版,这适用于我:

<script src="https://maps.googleapis.com/maps/api/js?v=3.0&key=YOUR_KEY&libraries=places" async></script>

我的临时解决方案:我选择了体验式的方案,https://maps.googleapis.com/maps/api/js?v=3.32 注意到在我的HTML的底部有一个标记,一旦你开始键入它,它就会更新,设置样式并得到修复。我发送了一个问题请求,希望他们能为稳定版本解决这个问题。

要使用标准功能而不是实验功能,具体需要做什么?在地图url中指定API版本为我解决了这个问题。谢谢@Julian SanchezI我收到谷歌地图API警告:RetiredVersionhttps://developers.google.com/maps/documentation/javascript/error-messagesretired-version 我想知道是否有更稳定的版本?有冻结的,新的版本,实验性的。可能是重复的
<script src="https://maps.googleapis.com/maps/api/js?v=3.0&key=YOUR_KEY&libraries=places" async></script>