嗨,我有困难,使自动完成显示像这里。我的代码用于提交并正确显示地图,但是没有显示自动完成的结果。我想知道会有什么问题。
这是我的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>这是我的Javascript:
var autocomplete = new google.maps.places.Autocomplete(document.getElementById('address'));下面是我对自动完成的调用,API已启用,我看到正在对数据进行调用,但没有返回结果:
https://maps.googleapis.com/maps/api/js?key=xxx&libraries=places&callback=initMap: {type: external, attributes: {async: true}}发布于 2018-03-01 20:42:28
Google在其新版本中有了新的安全性更改,使用3.0版本,这对我来说是可行的:
<script src="https://maps.googleapis.com/maps/api/js?v=3.0&key=YOUR_KEY&libraries=places" async></script>发布于 2018-03-01 18:49:57
我得到了同样的东西与非常相似的代码。对我来说,这段代码已经运行了几个月,就在今天,我从一位用户那里得到了一份报告,称下拉列表中的位置不再显示。
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);
});我在想,也许我们已经超过了每天的配额,但从Google控制台上看似乎并非如此。我在浏览器控制台中没有看到任何错误。如果我查看developer网络选项卡,我可以看到向https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetQueryPredictions发送的请求,但是响应似乎相当神秘(ex:**/xdc.490z0c& xdc._490z0c( 4)),因此我无法判断是否有好的数据返回。
我想知道最近谷歌方面有没有什么变化,我还没有听说过。
发布于 2018-03-01 21:19:31
我的临时解决方案:我使用了体验版https://maps.googleapis.com/maps/api/js?v=3.32,并注意到在我的HTML底部有一个标签<div class="pac-container pac-logo hdpi">,当您开始输入它的更新、样式和修复。我发送了一个问题请求,我希望他们将修复这个稳定的版本。
https://stackoverflow.com/questions/49055809
复制相似问题